

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Bangalore; Class: Parallel Computing; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Fall 2006;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Fall 2006 CS 432/632/732 Parallel Computing Homework-
Individual Work Only. 100 points. Due September 5, 2006.
Write a program in C/C++ or Fortran that performs the smoothing/sharpening operation on an image stored as a two-dimensional array of pixels. Use mean and median methods for smoothing and high-pass sharpening filter mask for sharpening (described in section 12.4.1 – 12.4.3 of the text, pages 374-379) to compute the new pixel values.
To simplify computation along the boundary (edges) use additional rows/columns (ghost cells) with the values set to zero as shown in the diagram below. Due to the additional rows/columns if the original image size is M X N then you have to allocate an array of size (M+2) X (N+2) (in this example, the allocated array size is 5 X 5 while the real pixel array size is 3 X 3).
0 0 0 0 0 0 1 2 3 0 0 4 5 6 0 0 7 8 9 0 0 0 0 0 0
Use the driver program provided as a starting point to complete the program. The program reads the name of PPM (portable pix map) image file in P3 format and a string to indicate which smoothing/sharpening method to apply (“mean” for mean method, “median” for median method, and “hpfilter” for high-pass filter) as command-line arguments. After performing the smoothing/sharpening operation (using the method specified by the command-line argument) the program writes the new image in PPM P format to a file with “-out” appended to the input filename. (Note that we are using PPM P3 format since it is easier to debug, in real applications we would use the PPM P format. P6 format uses binary values instead of ASCII values for the pixels, thus results in a smaller file size). The PPM format stores the pixel values for red, blue, and green colors; hence a two-dimensional array is used to store pixel values for each of the primary colors. For more details about the PPM format please see: http://netpbm.sourceforge.net/doc/ppm.html or type “man ppm” on a UNIX system.
Most of the program is already written, your task is to understand what the current program does and implement the three functions mean, median, and high-pass filter. Specifically understand the memory allocation routines alloc2Darray and alloc3Darray and the use of the function pointer – funcptr. Test the program with the different images provided along with the driver program. During initial testing using the small image file and after you have worked out all the bugs then try with larger file sizes. Note down the time taken for each operation with the different input files and complete the table below:
Time Taken (in seconds) Mean Median High-pass filter Image Image Image
Fall 2006 CS 432/632/732 Parallel Computing Homework-
Answer the following questions w.r.t the driver program:
Submission: Email the source code along with any scripts/Makefile and typed answers to the above questions (Text, Word, PDF, PS file) as a single tar/zip file attachment to [email protected] with the subject “CS432/632-Homework0.”
Resources: Driver program and input files for testing are available at: http://www.cis.uab.edu/cs432/software/index.html.