Negative and Grayscale

imagegram.py: 38 points


Now, you will implement two functions that modify the image, described below. You will not need to make a copy of the image for these functions: simply loop over the original image, changing the pixels as you go. For more information about how to use the picture module to modify an image, please refer to the documentation. All of the variables you use in your functions should be local, not global, variables.

Negative Filter

The negative of an image is created by inverting each color channel. So if the red value of a pixel were 255, it should become 0. If it were 254, it should become 1, and so on, down to 0 (which should become 255). Similarly for green and blue.

Negative Filter

Grayscale Filter

Shades of gray have the same red, green, and blue value. To convert an image to grayscale, you should set the red, green, and blue values all to the average value of the three channels of the original pixel. This filter is identical to the grayscale filter you designed in the warmup.

Grayscale Filter

Once you’ve implemented a function, add the ability to call it from your looping menu and make sure to test it!