The objectives of this assignment include the following:
- Using the methods given in class to create a Picture object from a jpeg file
- Manipulate all the pixels in a created Picture using a loops
- Use basic conditionals to control the sequence of statements executed
The basic output of this assignment is a new picture jpeg that is the posterization of a picture, which reduces the number of colors in a picture. We will accomplish this by writing one or more java applications that each perform a specific manipulation on a Picture. For any java program, once it manipulates the picture (and displays it), it should give the user the option of saving it to a file.
For basic completion of the assignment, which will earn 70 out of 100 points, complete the following:Write a Java application class named Posterize that posterizes a Picture. It must begin by interactively getting the filename of a picture. It then must create a Picture object from the jpeg file. Finally, it must iterate (using nested loops) over all the pixels in the picture and perform the following, per pixel, manipulation. The color of each pixel should be changed according to the following rules:
- If the red channel is at least 180, set it to 255
- If the red channel is at least 128 and less than 180, set it to 200.
- If the red channel is less than 128, set it to 64.
- If the blue channel is more than 128, set it to 192.
- If the blue channel is 128 or less, set it to whatever the red channel value has just been set to.
- If the green channel is greater than or equal to 192, set it to 192.
- If the green channel is less than 192, set it to 64.
Finally, the application should redisplay the image so that the changes appear. sThe program should then query the user to save the file.
For an additional 20 points (for a total of 90 out of 100), write a second Java application called RotateColors that performs the following transformation:
- Set the new red color for a pixel to the old green color of that same pixel.
- Set the new blue color for a pixel to the old red color of that same pixel.
- Set the new green color for a pixel to the old blue color of that same pixel
And, as before, redisplay the image and offer to save to a file.
Finally, for an additional 10 points, find some images and then either rotate them or posterize them (or both). Be creative and find images that have interesting and/or pleasing results. You may want to write a new version of the Posterize application (that you can name Posterize2) so that you can experiment with different values for the thresholds and values defined above. After creating a result, save the new posterized or rotated image to a new jpg file. Be sure and use either good filenames or include a short text file to describe what you have done. Some of the more interesting images you submit will be posted on the class webpage.
Turn In:In your Assignment Inbox, turn in each of your applications in a folder named HW7. Also in that folder, include both before and after jpgs.