Summary |
Read PPM image from file an ASCII file, alter RGB elements of each pixel, and print resulting image to a new file. Students will gain an understanding of basic image processing techniques, and an appreciation for image editing software that they may already use.
|
Topics |
|
Audience |
Appropriate for CS1, CS2, or later courses.
|
Difficulty |
This is an intermediate to
advanced assignment, taking about 2 weeks for a CS1 student. |
Strengths |
|
Weaknesses |
While the assignment may be simple to implement, students may have apprehension about tackling (what seems to be) a larger task than most intro assignments. |
Dependancies |
No language/library dependancies for student code. This assignment has been used in our departmetn in C++ and Python, but any language should suffice. The PPM image format is completely uncompressed, an therefore is often not employed in the real-world. Students will need software to view thte PPM images, should be available for any operating system. We have found solutions for several operating systems for viewing/saving PPM images (this list is not exhaustive): Windows: Irfanview (shareware) Apple: Graphic Converter (came bundled with some versions of OS X) Linux: GIMP Cross-platform: GIMP, Photoshop (available as a free 30-day trial) Our program uses Windows computers for CS1 or 2, and we had no problems with Irfanview. |
Variants |
Simple effects (requirements: loops, conditionals, file I/O): Color inversion, conversion to greyscale, contrast effects, brightness adjustment, random noise (requires random numbers, but is still pretty easy). Arrays can be avoided for simple effects because only one pixel needs to be in memory at a time (int R, G, B). Intermediate effects (additional requirements: arrays): flip image vertical, flip image horizontal, horizontal blur Intermediate effects require a horizontal slice of an image, or an entire image to be stored in memory at once (int R[MAX_WIDTH], G[MAX_WIDTH], B[MAX_WIDTH]) Advanced effects (additional requirements: 2D arrays) Vertical blur, bidirectinoal blur. For CS2 or greater level programs, this would make a great introduction to nested classes. The effects listed are just for example, students and instructors may come up with a variety of interesting additional effects. For instance, using only simple arithmetic instructors could add an advanced/bonus feature of applying effects to only a portion of the images (every nth row, every nth column, specific quadrants, etc.). |
Base Image (no effects)![]() |
Flip Vertical![]() |
Greyscale![]() |
Invert RGB![]() |
Zero-out GB![]() |
Extreme contrast![]() |
Horizontal blur![]() |
Random noise![]() |
Extra info about this assignment: