Homework #4 CMSC 131
Due February 26th, 2003 (was Feb 24th) Object-Oriented Programming I
  Spring 2004

 

Picture processing, Part 2

This homework will give you more experience working with pictures, writing more expressions and statements. As with previous homeworks, you must also submit a time log.  This homework is to be done alone. It will be graded as follows:

Your Assignment

For this homework, you must write some more picture classes (i.e., programs).  Each will create a picture by implementing the Picture interface.  You must name your picture classes as follows:

    

Now, how would you posterize a picture? For starters, you posterize a picture by posterizing each pixel.  And you can posterize a pixel by posterizing the red, green and blue components of each color. But, how do you do that? Well, each color component has a value between 0.0 and 1.0. To posterize it, you need to restrict components with values <= 0.5 to 0.0 and with values > 0.5 to 1.0. Think how you might use an "if" statement to transform a color component from the range 0.0 - 1.0 to having the discrete values of either 0.0 or 1.0.

To manipulate colors, you can use the PictureColor.getRed(), getGreen(), and getBlue() methods to get each color component.  Then, after you have computed all three new color components, you can construct a new color with those values and return that.  Documentation for these and all methods provided for this homework is available online.

Your constructor must have the signature:

    public Posterize(Picture basePicture);
 

    

Your constructor must have the signature:

    public Inverse(Picture basePicture);

 

 

You can assume that the base picture's getColor() methods will always return valid PictureColors, even if the x and y values are outside the bounds of the pictures. For (x,y) values outside the dimensions of the base picture, you should return whatever color is returned by getColor() of the base picture. [This paragraph updated to reflect a copy & paste error, Feb 21, 6pm].

Your constructor must have the signature:

    public Offset(Picture basePicture, int newXOffset, int newYOffset);

 

You can assume that the base pictures' getColor() methods will always return valid PictureColors, even if the x and y values are outside the bounds of the pictures. For each (x,y), you must blend whatever colors are returned by getColor() for the two base pictures, even if that (x,y) is outside the range of one or both of these base pictures.

Your constructor must have the signature:

    public Blend(Picture basePicture1, Picture basePicture2);

 

Since this is a private project, you can submit your time log as part of the project.  Just edit the timelog_hw4.txt file that is distributed with the hw4 project.

Submit your program by right-clicking on your project and select "Submit Project". Note that this option will only appear if you have successfully installed AutoCVS as described previously.  If you decide that you would like to make a change after you have submitted your project, you can resubmit as many times as you like before the extended deadline.  We will grade the last project submitted.

/* Name
 * Student ID
 * Homework #4
 */

<your code goes here>

Challenge Problem

For an extra challenge, do something creative.  Build on everything you've done so far to create some fun picture based on two input pictures. Your constructor should have the signature:

    public MyPicture(Picture basePicture1, Picture basePicture2);

As with the previous homework, you must include a short comment that describes what MyPicture does and how it works.  Please post your most interesting work in the homework #4 gallery.