Image-6 Exercises

< CS101

1.

Red Golden Gate - the image golden-gate-red.jpg shows the golden gate bridge, but all of the data is in the red values.
golden gate bridge, shown in red

Write code that for each pixel copies the red value over to be the green and blue value. The result will be to change the image to grayscale which will look better.


image-6-ex1

2.

Gray Banana - write code to change the banana.jpg image to grayscale.
a yellow banana

Write code to change the banana.jpg image to be grayscale. Reminder: here is the line used in the loop to compute the average of the red/green/blue values and store that value in a variable named "avg".

  avg = (pixel.getRed() + pixel.getGreen() + pixel.getBlue())/3;


image-6-ex2


Each click of a Run button saves that code to disk on the computer running the browser. The button below retrieves the code exercises listed to the right of the button.

count 2 : image-6-ex1 image-6-ex2

(code appears here)