

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


In this assignment you will write a Python program that does some elementary image processing.^1 A Python class called Image will be provided for you that reads in images, lets you access the pixels (stored as red-green-blue integer tuples), and lets you write the image back out. The main methods are:
See the file Image.py for a full description of what these methods do, and what the arguments mean. The Image class encapsulates a very simple image reader/writer. It can only handle images that are in “PPM” format, which stands for “Portable Pixel Map.”^2 If you wish to run your program on other images, you will need to first convert them into PPM format.
You are to create and submit a Python module named “hw8.py” containing definitions for the following functions (with precisely these spellings, including case):
Be sure to submit only working Python code and comments. This should be a fully functional program that imports Image.py. Here is what the functions should do:
PixelDiff(( 5 , 128 , 90 ), ( 30 , 7 , 91 ))
should return the value 121, because the second (green) components differ by 121, and this difference is greater than the difference in the other colors (25 and 1 in this case). (^1) You may choose to do homework 8 instead of or in addition to this homework 7. Your grade will be based on seven (7) assignments; if you do all eight (8) assignments, your lowest score will be dropped. (^2) This is such a trivial format that some image viewers don’t even support it. Those that do include Photoshop and Irfanview; the latter is freeware that you can download from the web.
Demonstrate your programs on one or more images. Include the original images as well as the processed images in a folder called hw8-results. Also include a README.txt file that describes what the images are, and what values of epsilon you used. Submit this zipped (compressed) folder along with your Python program. You are encouraged to find your own images to process. All of the machines in the lab have Irfanview installed, which will allow you to view PPM images, and also convert other formats to PPM, juch as jpeg and gif.