Overview

In this reading we’ll look at some advanced image filters that utilize our newly acquired understanding of conditional statements. Specifically, we’ll look at how image blurring works and why green screens are widely used.

Required Reading

Sections 6.4 - 6.8 (pp. 194-207) from the course textbook.

Learning Objectives

BASIC Learning Objectives

Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.

  1. Describe how the “blur” filter modifies a Picture object.
  2. Given a picture and a set of pixel coordinates, determine if accessing those coordinates will lead to an ArrayIndexOutOfBoundsException error.
  3. Describe how green screens are used to facilitate background substitution in an image.

ADVANCED Learning Objectives

The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.

  1. Write, read, and trace code that either loops over some portion of a picture and accesses multiple pixels on each iteration.

Pre-class Exercises

These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.

  1. Consider the following Java code, which makes use of the blur method from your book.

    Picture p = new Picture(FileChooser.pickAFile());
    p.blur(2);

    Part A: For the pixel at (0,0), what will be the smallest value used for xSample and the largest value used for xSample? What about for ySample?

    Part B: For the pixel at (0,0), what value will be in the count variable when computing newColor?

    Part C: For the pixel at (10,10), what will be the smallest value used for xSample and the largest value used for xSample? What about for ySample?

    Part D: For the pixel at (10,10), what value will be in the count variable when computing newColor? Hint: This should be a different value than the one you got in Part B.

    Part E: In your own words, explain why the answers in parts B and D were different (i.e. why wasn’t count the same in both cases?)