EE599 Assignment 3: A Little Off

This is a simple assignment for EE599 students only. Rewrite the following code so the same operations are performed, but performance is optimized. The best speedup will require use of SWAR concepts and MMX instructions (for example, using the ars-swar.h MMX/3DNow! macros for GCC), but significant improvements also can be made in other ways. In any case, you're not done optimizing until you achieve at least a 1.25x speedup as compared to the original.

The Computation

Given two same-size P6 PPM-format 24-bit color image files, this program memory-maps both images and determines the small offset that best aligns the two images (as explained in class).

Although in class I had suggested using the squares for the pixel color-channel distances, this code simply uses the sum of the absolute values of the pixel color channel distances... and your code should too. Also notice that the sum is 32-bits; although that isn't good enough in general, you should assume that the worst difference values you'll see will fit in a 32-bit unsigned int total. I also simplified things by limiting your concerns to just two functions.

The source code is reg.c and I also have provided two test images: horse.ppm and horsea.ppm. If you compile reg.c to make an executable called reg, then ./reg horse.ppm horsea.ppm would print bestdx=6, bestdy=4. Incidentally, the difference between them with that offset, as measured by this program, is literally 0. You should get the exact same offsets for ./reg horse.ppm horseb.ppm, since horseb.ppm is simply a noisy version of the horsea.ppm image.

To make things easier for you, here's a 7MB TAR file of the source code and test images. Notice that only the PPM files are big; reg.c is only 201 lines long and you are changing even less that that. You only should be changing the marked section; i.e., replacing diff() and perhaps bestoff().

In case you were wondering, the images are 1024x768 each and were derived from a 5 Megapixel master that looks like:

Due Dates & Such

This project is due by 10:29AM, Thursday, May 8, 2003 (one minute before the final exam time; there is no final per se, but you are expected to show up for the EE699 student presentations). Submit the following:

Submission Form

Submit a tarball of your project here:

Your email address is .

Your password is .

Although this is not a secure server, users are bound by the UK code of conduct not to abuse the system. Any abuses will be dealt with as serious offenses.


Advanced Program Optimization & Parallelization.