Question: Assignment 3 Pixel Tinting! #java #javaProgramming Part 3 Go blurry! Write an averaging function to blur your headshot. Part 3 Go blurry! In this part

Assignment 3 Pixel Tinting! #java #javaProgramming

Part 3 Go blurry! Write an averaging function to blur your headshot.

Part 3 Go blurry!

In this part of the assignment, your objective is to write a method in Picture.java

that will blur an image by averaging each pixel with the pixels that come before

and after it in the pixel array. So, for a random pixel with index i" in your

pixelArray, the red value of i should be the average of the red values of pixel i

(the pixel i points to), pixel i-1 (the pixel to its left), and pixel i+1 (the pixel to its

right). The same should be true of the blue parts of the pixel and the green parts

of the pixel.

Assignment3Part3.java has some starting code in it for you. In the Main()

method, write code that will load in a headshot image called myHeadShot.jpg

(you will have to rename your photo to this). The important code we have

provided for you in Appendix B below is a separate method called

averagePixelsHorizontally(). Copy this method into your Picture.java file and

work on it there.

Note that there are two special cases in this method that you have to think

about:

The very first pixel in the array can only be averaged with the pixel after

it, since there is no pixel before it.

The very last pixel in the array can only be averaged with the pixel before

it, since there is no pixel after it.

We have created an IF statement that checks for these special conditions. All you

have to do is fill in the code for what happens in the two special conditions and

in the normal condition of a regular pixel anywhere else in the array. Note that

these special conditions at the beginning and end of an array are often called

edge cases. Processing edge cases properly is an important part of

programming.

We suggest getting the standard case to work first, and then going back and

writing the code for the special edge cases.

Once you have written the averagePixelsHorizontally method, you will want to

test it, perhaps using the picture.explore() functionality to see the results.

However, this averaging may be hard to detect visually after a single averaging

call. We suggest that in your Main method() you call the

averagePixelsHorizontally method at least three times so that you can see the

blurring effect. You should probably write a loop to do this. You might also

consider calling the averaging method many more times to see what the effect is.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!