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.
Sections 6.4 - 6.8 (pp. 194-207) from the course textbook.
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.
ArrayIndexOutOfBoundsException
error.The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.
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.
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?)