Duke CS Logo CompSci 100e: Program Design & Analysis II
(Fall 2009)
Home
Course Information
Calendar
Resources
Assignments
APT problems
Lab
Lab 1 - 08/28
Lab 2 - 09/04
Lab 3 - 09/11
Lab 4 - 09/18
Lab 5 - 09/25
Lab 6 - 10/02
Lab 7 - 10/09
Lab 8 - 10/16
Lab 9 - 10/23
Lab 10 - 10/30
Lab 11 - 11/06
Lab 12 - 11/13
Lab 13 - 11/20
Lab 14 - 12/04
Help sessions
Discussion Forum
Blackboard
Oasis

Week 3, 9/11

Prelab Exercises

  1. Complete problems 1-5 from WordCount in-class problems. Turn the answers in (on paper) at the beginning of lab.

  2. Review the first page of a tutorial on computational representations of colors and the API for the java.awt.Color class.

Lab Exercises

Snarf the pixmap project frpm the course assignment folder.
  1. Review 2D array manipulation:
    1. Review the execute method in Command.java. What does it do?
      
      
      
      
      
      
      
    2. How do the transform methods in Brighten, Darken, GreyScale, Negative, Posterize, and WeightedGreyScale relate to the one in Command?
      
      
      
      
      
      
  2. Colors

    After referring to the first page of a tutorial on computational representations of colors and the API for the java.awt.Color class, answer the following questions.

    1. Why is RGB a good representation for representing colors on a computer monitor (instead of CMYK, for example)?

      
      
      
      
      
    2. Given 256 different levels each of red, green, and blue, approximately how many colors can be represented?

      
      
      
      
      
    3. How are grey values represented in the RGB color space?
      
      
      
      
      
  3. Pixmap Transforms:
    1. Negative
      Create a photographic negative of the image by inverting each of the three RGB components of the current color. For example, if the current color has the values (255, 0, 128) for its red, green, and blue components, respectively; then the resulting color should have the values (0, 255, 127) for its red, green, and blue components. In other words, each value is the other's opposite within the range of possible values from 0 .. 255. Thus, if this operation is performed on an image twice in succession, the image would appear unchanged.
    2. Darken
      Darken the image by reducing the values of each of the three RGB components of the current color by some amount (like the darker method of Java's Color class). Do not call the method, instead you will try to reproduce its effects by manipulating the three RGB components of the current color directly. Note, this method should exactly undo the results of performing the Brighten action (as long as any of the image's colors are not already as bright as possible), so that doing one operation then the other should result in no net change in the image. Be careful not to produce a color value outside the range of possible values from 0 .. 255.
    3. Brighten
      Brighten the image by increasing the values of each of the three RGB components of the current color by some amount (like the brighter method of Java's Color class). Note, this method should exactly undo the results of performing the Darken action (as long as any of the image's colors are not already as dark as possible), so that doing one operation then the other should result in no net change in the image.
    4. Posterize
      Create a posterized version of the image by reducing its total number of colors. To do this, you should restrict the values each of the three RGB components of the current color can be. Specifically, if the value of a component is between 0 and 63 inclusive, it should be set to 49; if the value of a component is between 64 and 127 inclusive, it should be set to 98; if the value of a component is between 128 and 191 inclusive, it should be set to 147; and if the value of a component is between 192 and 255 inclusive, it should be set to 196. In this way, the 256 possible values each component can have is resticted to just 4.

    5. GreyScale
      Create an image that has only shades of grey values by computing the average value of the current color's three RGB components and using that average value for all three components of the new color. For example, if the current color has the values (255, 0, 128) for its red, green, and blue components, respectively; then the resulting color should have the values (127, 127, 127) for its red, green, and blue components.

    6. Weighted GreyScale
      Create an image that has a "better" greyscale transformation. such that it uses the weights suggested in this article and see if you notice a difference in the image quality. The main idea of the article is to weight the three color components differently, i.e., create a grey scale value based on taking 30% of the red component, 59% of the green component, and 11% of the blue component. For example, if the current color has the values (255, 0, 128) for its red, green, and blue components, respectively; then the resulting color should have the values (90, 90, 90) for its red, green, and blue components.

    Submit

    For this lab, the Brighten, Darken, Negative, Posterize, GreyScale, and WeightedGreyScale will NOT be due now. Instead, they will be due at the same time as the rest of the Pixmap assignment.

    For this lab, submit:

    1. The answers to question 1 and 2 (Colors) above in a file called lab03.txt
    2. A README.txt file including your name, NetID, collaborators, resources used, and how many of the functions (Brighten, Darken, Negative, Posterize, GreyScale, and WeightedGreyScale) you finished during the lab period.
Last updated Fri Dec 04 11:33:59 EST 2009