CSN 455 - Image Processing	Programming Assignment 2 - Due Tuesday, Mar. 4

For this assignment, you will perform some timing studies on several aspects of an image processing problem and comment on the results.

In the directory called IP in your home directory on eckserver , create a subdirectory called TIMING. Copy the files from / usr /local/classes/ csn455 /ENHANCE as a start for your program or use your own enhance program from programming assignment 1. We will focus on the computation of the square root transformation from program 1. If you have not implemented that particular transformation, the following lines would achieve the desired result and are typical of most solutions which were submitted.

for ( i =0; i<rows ; i ++){

for (j=0; j<cols ; j++){

newdata[i ][j] = (unsigned char)( sqrt ( data[i ][j])* sqrt (255));

}

}

In order to time the above section of code we would add the following lines to our c++ program:

clock_t start = clock();

(Code to be timed)

cout << "elapsed time sqrt = "

<< (clock()-start)/(double) CLOCKS_PER_SEC << endl ;

You will also need to add the following include statement:

#include < time.h >

Perform the following timing studies and create a file called results in which you will summarize the results of your testing . The file will also be used to include responses to various questions concerning your results. Be sure to include your name at the top of the file and the name of the computer on which you have done your timing study. (For example: eckserver , dirac , curie, etc.) Label any numbers or program outputs appropriately with a brief description of what you are timing. For the puposes of this study you should use the image in / usr /local/images named frisco_bay.pgm

Timing Study #1:

Time the code which performs the square root transformation of your image (similar to the code above). Repeat the process five times and paste the timing output from each run in the results file. Compute the average of the five runs and include that as well.

Timing Study #2:

Now, move the computation of sqrt (255)outside of the loops (but inside of the timer). Recompile your program and compute the average time over five runs. Paste the timing output from each run in the results file along with the average. How many calls to the square root function have you eliminated with this change? How do the execution times of two versions compare? Comment on what may account for the difference.

Timing Study #3:

There are a maximum of 256 different values in your original image, however if the sqrt ( data[i ][j]) is still computed inside of the loop, the square root function is called many more times than necessary. Create a floating point array of 256 elements. Compute the square root of each of the possible pixel values from 0 to 255 and store them in the array. Now inside of the loop, set the values of newdata by looking up the appropriate square root values in the array instead of computing them each time. Recompile your program and compute the average time over five runs. Paste the timing output from each run in the results file along with the average. How many calls to the square root function have you eliminated with this change? How do the execution times of this version compare with the version you timed in timing study #2? Did you see the same amount of improvement as in study #2? Comment on what may account for the difference.

Be sure that you change the permissions on your source file as well as those on your results file. You may use the following command:

chmod go-r enhance.cc

chmod go-r results

You program should be named enhance, and should have the following command line format:

enhance frisco_bay.pgm whatever.pgm -sq

By the due date, be sure that the following two files are available in your IP/TIMING directory:

enhance.cc

results

I will expect to see the final code which was used to for timing study #3.