Image 6 Exercises

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.


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;