Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 3 Pixel Tinting! Part 1 Go psychedelic! Make a tinting animation of your own headshot. Part 2 Go Dutch! Merge your headshot with a

Assignment 3 Pixel Tinting!

Part 1 Go psychedelic! Make a tinting animation of your own headshot.

Part 2 Go Dutch! Merge your headshot with a transparent Royal Dutch Navy flag.

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

Part 4 Animate! Make an animation of your headshot that goes psychedelic for

awhile, then goes Dutch, and then slowly gets more and more blurred.

Part 1 Go psychedelic! (20%)

For Part 1 of the assignment, use the base code Assignment3Part1.java as a

starting point. In the Main() method, there is already code that will load in a

picture from the command line or allow you to choose a picture to load. You

must change the program to call at least three different color methods to tint

your headshot different shades. There are already calls to the

Thread.sleep() method to pause the image for awhile, so you can

see your changes. In the end, you should have an animation of your own photo,

changing colors. The color-tinting methods should be written in your

Picture.java class. Make sure that you have three different methods that tint your

face at least three different colors. Whether or not you use parameters to be able

to tint at varying levels is up to you (in other words you could have a method

that always tints your picture red by 50%, or you could have a method that tints

your picture red by a percentage as a parameter).

Part 2 Go Dutch! (25%)

For Part 2 of the assignment, you are to use base code Assignment3Part2.java as

a starting point. The objective is to create a program that merges your headshot

with the historical flag of the Royal Dutch Navy:

Hint: Use a while loop to loop through the pixels in your image, tinting the first

third of the pixels orange, the second third of the pixels white, and the last third

of the pixels green. Note that you want to move the RGB values towards orange,

white, or green but not completely because then it would just look like the flag

image above.

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). You should

accomplish everything you need to do in the Main() method of

Assignment3Part2.java.

Part 3 Go blurry! (20%)

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.

Part 4: Animate! (20%)

Make an animation of your headshot that goes psychedelic three or four times,

then goes Dutch, and then slowly gets more and more blurred. Place this code

into a file called Assignment3Part4.java.

You can use the

Thread.sleep()

method (see Part 1) to

pause the image for a while between each change (remember: 1,000

milliseconds is 1 second).

Coding Style (15%)

This grade is awarded for proper coding style. This includes:

Appropriate method, variable, field, object and class names

Proper indentation

Good commenting (explains what code is doing)

Well-organized, elegant solution

What to submit:

Assignment3Part1.java

Assignment3Part2.java

Assignment3Part3.java

Assignment3Part4.java

Picture.java

headshot.jpg (the image you used for this assignment)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

What is an audit internal control questionnaire?

Answered: 1 week ago