CS/ECE 545 Homework 1

Complete by Class 2

Computer Accounts

Get a WPI computer account at the CCC workstation room at the top of the main stiars in Fuller Labs or by e-mail to system@wpi.edu.

Get a CS account by e-mail to system@cs.wpi.edu. Be sure you've arranged the WPI account first since your login name and password will be duplicated. Afterwards, you can change your two passwords independently - just use the UNIX passwd command.

Image Processing Program Shell

Write a program (or programs) which reads an image, processes it, and writes an output image file. Prompt the user for the input/output file names. Use C, C++, or Java and use the standard file format. Hand in your program(s) in class.

  1. Rotate the image 90° in some direction.
  2. Invert the image (white -> black and black -> white).
  3. Replace each pixel by the average of four adjacent pixels in some direction. Be sure your program handles image edges gracefully (make sure it doesn't crash. Don't worry about getting the "correct" pixel values on the edges).
  4. Make a picture one-half the number of pixels in each direction. Replace each pixel with one containing the average of four adjacent pixels in the original image. Be sure your program works with both odd and even numbers of rows/columns.


This is only one possible solution. Mileage may vary.

See the new and improved software utilities in the software library The program consists of the following common modules. The software is available by following the links below:

img.h the usual definitions. This is used in all other program files.
img.c - utility functions for managing image structs and functions for reading and writing image files in the standard format.

Note: gif versions of the images are here.

There are four versions of main(), corresponding to the four programming assignments.

hw01a.c - rotate an image 90° clockwise
hw01b.c - invert an image
hw01c.c - blur an image using averaging in a 2x2 pixel neighborhood
hw01d.c - reduce image size to half using averaging in a 2x2 pixel neighborhood

The image leonardo1 was used in all four examples, but the code works properly with grayscale images, too.

Note that these are classical C programs except that structs are used for images. That makes it straightforward to transform this code into C++.

CS/ECE 545 Staff
Contents ©1997 - 2011 Norman Wittels and Michael A. Gennert