CS 111: Introduction to Computer Science

Image Processing

Due: 11:59PM Wednesday, November 4. Hand in as images.py.

If you have ever used image-manipulating software (e.g. Adobe Photoshop), you know that you can do lots of crazy things to digitized images. Some of the games you can play involve very complex mathematics, but others are pretty easy. For example, turning a color image into a black-and-white image is easy: for each pixel, take the average of the pixel's red, green, and blue values, and use that average as the new red, green, and blue values for the pixel.

There is a nice image-manipulation library for Python known as the Python Imaging Library, or PIL. You will use PIL to implement a few wacky image transformations.

More specifically, for this assignment, you will implement the functions whose interfaces are specified in images.py. Do not change the interfaces in any way. When you hand in your program, please include the original testing code, found at the bottom of images.py.

More details

The images.py file has two sample functions already written: getGreenImage and getSmallImage. If you were using this picture of my children harrassing Babe the Blue Ox in Bemidji, Minnesota a few years ago:

and you executed this code:

image = Image.open('ox.jpg') greenImage = getGreenImage(image) greenImage.show()

you would end up with this:

Your job for this assignment is to implement the functions getMirrorImage, getGrayImage, and getRotatedImage to yield images like these:

By the way--the grader will test your code using an image file of his own choosing, so you should test your code on more than my example image.

Have fun.