Image-8 Exercises

1.

Here is the fence-ivy.jpg image.
red fence with green ivy

Write code that picks out the pixels of the green leaves in the image (using the > avg * factor technique, as in lecture). For each green pixel identified, set its green value to 0. The result is that the green leaves are changed to a sort of weird purple color, since setting green to 0, we just have red and blue contributing.


image-8-ex1

 

2.

Here is the stop.jpg image.
stop sign

Write code that picks out the blue sky (using the > avg * factor technique, as in lecture). Change the blue pixels to be dark gray red=20 green=20 blue=20 .. so it looks like nighttime. Adjust your code so it changes the sky, but not the white letters in the sign (which are technically a little blue).


image-8-ex2

 

3.

Here is the curb.jpg image.
red curb

The goal for this problem is to change the curb to look blue so we can get a much more expensive parking ticket. Detect the red pixels of the curb using the avg technique as usual. For each pixel, change its red and green values to be half the average value, and change its blue value to 1.2 times the average value. In effect, this sets red and green low and blue high, making it look kind of blue. Note that the blue effect will also apply to the reddish plants off to the right as well -- now they are blueish plants.


image-8-ex3

 

4.

This is basically the flip of the previous problem. Instead of detecting and changing the red pixels, detect all the pixels that are not red. Change the not-red pixels to be grayscale. The result will be that the reddish parts of the image are unchanged, but everything else is now a dead gray color.


image-8-ex4

 


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

count 4 : image-8-ex1 image-8-ex2 image-8-ex3 image-8-ex4

(code appears here)