Computer Science I

PA 01

Simple modifications to an entire picture


Code due by Friday, February 6th at 9:00 AM

Paperwork due the same day at the start of class


Make sure you read the directions carefully.  This assignment consists of several pieces and you need to complete all of the pieces for full credit.

 

Task 1

In lab3 you used recipe # 8 to cut the red value in half, and recipe #9 to increase the red value by 20% (multiplying by 1.2 is the same as increasing by 20%). 

These methods are fine if you want to change by that given factor (0.5 and 1.2) but what if you don't?

Write a method called modifyRed() which takes two parameters.  The first is the picture to modify.  The second is assumed to be a float value between 0.0 and 2.0 which is the degree or factor by which the red should be changed.  For example:

        >  modifyRed(picture , 0.5)

should produce the exact same results as

        > decreaseRed(picture)

while

        > modifyRed(picture , 1.2)

would be the same as

        > increaseRed(picture)

Make sure you test your new modifyRed() method with several groups of parameters to verify that it does what you expect.

Task 2

Recall that we defined "gray" to be any color where the red, green, and blue values in a pixel are all equal.  For example, makeColor(128,128,128) produces a middle of the scale gray.  Thus, there are 256 gray colors in the representation of color we use in this class. 

Furthermore, recall that grayscale images are any picture where every pixel is set to some version of gray.

In class we worked through recipe #16 to create a grayscale image where each pixel's luminance is set to the average of it's three components.  This is, however, only ONE way to determine which version of gray to select for a pixel.  In this activity I want you to explore different methods for selecting the intensity value to which  you set each pixel.

Create at least three additional versions of makeGrayscale (let's call them makeGrayscaleV1, makeGrayscaleV2, etc).  You may and in fact are encouraged to create more than three versions.  Each version should use a different technique of selecting how you map a colored pixel into a gray pixel.  For example, you could use the intensity of one particular color component.  Or, you might use interesting combinations to weight the red, green, and blue components of a pixel differently when creating the intensity value. Whatever technique you chose, you should make sure that your mapping has the potential to create all valid colors of gray.

After you have created at least three versions, test them all on the same picture and compare the results.  Write up a short description of your experiments in a text file (not a Word document!) named "grayscale-experiment.txt". Be sure to say which of the grayscale versions of your image seems to be the most faithful to the original -- and why you think that version looks better than the others.

Make sure to submit your "grayscale-experiment.txt" file for final submission.

If you have questions about ideas for different makeGrayscale() methods you should talk to Dr. Schafer.

Task 3

If you think of "old fashioned" photographs like cowboy photos from the American West of the 1800s, you probably don't actually think about grayscale photos but instead you think of sepia-toned photos.  Sepia tone was a printing technique that gave photos a sort of yellowish color rather than gray. 

For example, here is the same photo in color, grayscale, and sepia-toned:

Color version Grayscale version Sepia-toned version

 

Using the color values recommended by Microsoft and referenced on the wikipedia website (see below) create a method called makeSepiaTone() which takes a picture as a parameter and converts that photo to sepia tone.

R' = (R * 0.393 + G * 0.769 + B * 0.189)
G' = (R * 0.349 + G * 0.686 + B * 0.168)
B' = (R * 0.272 + G * 0.534 + B * 0.131)

[NOTE #1: This formula will produce RGB values greater than 255 if the original color is close to white.  This can cause problems if you try to use these invalid values in certain methods.  Use what we discussed in class in Session 7 to avoid these problems].

[NOTE #2: your textbook mentions sepia-tone in chapter 4 but uses a VERY different technique than I am requesting.  Do NOT submit the code used in chapter 4 of your textbook for this assignment.  If you do you will receive no credit for this task].

Grading

To upload your homework for grading, log on to the homework submission system at:

Your id and password for this system are the same ones that you use to log on in the labs.

Follow the directions on the system to select the appropriate course and assignment and submit the following

In addition to this, you should print paper copies of your code and your essay and submit these at the start of class on the due date.