imagegram.py: 38 points
Next, you will choose your own filter to implement! You can choose from one of the following, or make up your own.
When you blur an image, you set the color of each pixel to be the average of the 9 pixels in the 3 x 3 square centered at that pixel (i.e., the average of the original pixel and its original 8 neighbors). You’ll probably want to create a copy of your image; otherwise, you’ll be adjusting pixel values that you’ll need for subsequent calculations. Be careful at the borders, not all pixels have 8 neighbors!
A typical pixel can have one of 256 value for each color channel. In a posterized image, this number is drastically decreased. Each color channel value should be rounded to the nearest multiple of 64.
When increasing the contrast, color values at 128 should be unchanged. For any other value
val, the difference between
val and 128 should be scaled a factor of two. For example, a color value of 129 (1 above 128) would become 130 (2 above 128). 125 (3 below 128) would become 122 (6 below 128). Just remember that you’ll need to stay between 0 and 255.
Add your function to the menu and test it out!