Image 4 Exercises

Here we'll do 5-10-20 puzzles like the one shown in lecture. For each puzzle image, the red, green, and blue values have been divided by a factor of 5, 10, or 20, but you don't know which factor was used on which color. Write code to fix the image, multiplying each color by 5, 10 or, 20 to get them back to their original values. Reminder: here is the line to use in the loop to multiply, for example, the red value of each pixel by 20:

  pixel.setRed(pixel.getRed() * 20);

There are a few solutions that look somewhat correct, but just one solution that looks exactly right. Figure out that solution.

1. Write code to fix the 51020-poppy.png image which should show an orange California Poppy in the foreground (the California state flower!), with a green and brown out-of-focus background.


2. Write code to fix the 51020-stop-sky.png image which should show a red stop sign with a background of a light blue sky and green tree leaves.


3. Write code to fix the 51020-oranges.png image which should show a box of oranges. The box itself is dull gray. The sign on the box is black, with "organic" written in light orange, and the rest of the letters are white.