CS 117 Assignment: Jeff's Family (assignment versions A & B)


Meet Jeff Ondich, the CS prof that is teaching the other section of 117.

Jeff Ondich

Jeff prepared the content of this assignment, and thus you get to meet his family as well.

Last spring break, Jeff and and his family went to England. One day, sitting on the London Underground after a long day of sightseeing, he noticed a perfect photographic opportunity: his son, daughter, and wife were sitting across from him, wearing red, green, and blue jackets, respectively. "RGB" popped into his brain, so he snapped a quick picture.

Could you make the whole image negative, with whites turned to blacks, darks to lights, etc.? Notice the red jacket on Sam (Jeff's son on the left): could you make his red jacket purple without changing the rest of the picture? If so, what would happen to his eyes or lips? Could you replace his jacket with another image--perhaps the water in the left side of this picture (from San Diego's Seaworld, a few years earlier)?

The answer is surely yes: you could do all those things, and thus, I'm going to ask you to do so.

You can think of a digital image as a long array of pixels, each of which has a red value, a green value, and a blue value, each of which is an integer between 0 and 255. Suppose, for example, that you have an image that is 200 pixels wide and 100 pixels high. Pixel numbers 0 through 199 pixels in our imaginary array form the top row of the image, pixels 200-399 form the second row, etc.

The class EasyBufferedImage gives you some tools for manipulating standard image files of type jpg, gif, or png, using an array like the one described above. To get started using this class, first retrieve copies of EasyBufferedImage.java and ImageProcessorTest.java from the /Accounts/courses/cs117/dmusican/jeffsfamily directory. While you're at it, save copies of the pictures above: jackets.jpg and water.jpg.

Your mission is to create a class called ImageProcessor that contains a EasyBufferedImage object as a private variable. You should then write the following methods:

Test your program by using ImageProcessorTest.java. Comment out the portions of ImageProcessorTest.java that refer to methods that you haven't written yet so that you can test your code as you go.

Note that though I have provided you with two images to use for testing, you are welcome to use your own images. The only real restriction is that the two images you use for the replaceRed(EasyBufferedImage replacementImage) method need to be the same size. Two images from the same digital camera with the same settings usually work fine. If not, you can use lots of kinds of software (e.g. the Paint program that comes standard with Windows) to modify the sizes of existing images.

Assignment "A" consists of getting the constructor, show, onlyRed, and negate methods working, and is due on Friday. Assignment "B" consists of getting the two replaceRed methods working, and is due Monday. (You should turn in your entire ImageProcessor class, including the first four methods, when you turn in assignment "B".)

Good luck, and have fun.