Computer Science 132: Analysis of Algorithms

Assignment 1

Part 1 due Tuesday September 15 before 23:00

Part 2 due Tuesday September 22 before 23:00

For this assignment, you will be working with images represented by pixel maps. Inside the directory ~miller/cs231/hw1, you will find a collection of files that use the Image class to implement a simple program that reads in an image file and displays a black and white image using ASCII characters. Your assignment will be to extend the Image class and create a user-friendly menu-driven program for manipulating, displaying and saving images.

Also in the hw1 directory are several pixelmap files, each having a img suffix. The have the following format:

Part 1

The display member function currently presents a black and white image. However, because some ASCII characters use more "ink" than others, it is possible to display pixels with more gradation. Referencing the DISPLAY_CHARS constant defined in image.h, modify the Display function so the image is displayed with grayscale characters. The characters listed first in DISPLAY_CHARS should represent light pixels whereas the last characters in the string should represent dark pixels. You may want to experiment with the contents and length of DISPLAY_CHARS to achieve the best quality display.

Part 2

Extend the Image class so that it has the following member functions:

Furthermore, you should create a user-friendly menu-driven program that uses your extended Image class. Your goal is to manipulating and displaying the image as easy as possible for the user.

Getting started

We will discuss the logistics of setting up your files. You will have created a cs231 directory in your computer science account. Inside your cs231 directory, you should have a hw1 directory that holds the files to this assignment. You will need to make your files readable to the instructor but not to other students. To do so, execute the following command from your home directory: chmod 705 cs231.