

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Program # Due date: Monday, May 12, 2003
A) Write a function that computes the 2-D Discrete Fourier Transform (DFT) and another function that computes the inverse 2-D Discrete Fourier Transform. A complex class and a display class for com- plex images (such as those resulting from a Fourier Transform) are provided for you (along with sev- eral other .h files that you will need) in the directory /usr/local/classes/cs/cs519/prog3/
The complex image display class is called FourierView and allows multiple ways of viewing the complex image values. You can either use the complex class provided in the above directory or you can use the standard C++ class (which is a template class). The complex class provided is easier to use than the C++ class since the provided class allows for direct access and manipulation of the real and imaginary components of the complex data type. However, if you prefer using the built in (C++) complex class, be sure to un-comment the line containing #define TEMPLATE_COMPLEX
in the file “define.h” so that it includes and uses the template class.
An image and its DFT should be displayed side-by-side in the same window (using a QHBox). You should also allow multiple images to be loaded and displayed simultaneously where each image/DFT pair is displayed in a separate window. The images to load and display are to be specified on the com- mand line ( 10 pts ).
B) Load any two grayscale images that are the same size from the following list of images (and display them along with their DFTs): /usr/local/classes/cs/cs519/images/ball.pgm /usr/local/classes/cs/cs519/images/goldhill.pgm /usr/local/classes/cs/cs519/images/gull.pgm /usr/local/classes/cs/cs519/images/hat.pgm /usr/local/classes/cs/cs519/images/office.pgm /usr/local/classes/cs/cs519/images/tulip.pgm /usr/local/classes/cs/cs519/images/boat.pgm /usr/local/classes/cs/cs519/images/flower.pgm /usr/local/classes/cs/cs519/images/garmisch.pgm /usr/local/classes/cs/cs519/images/interfere.pgm /usr/local/classes/cs/cs519/images/peppers.pgm
(As with the previous programming assignments, you may want to create symbolic links to the images you use, or at least to the images directory above). Swap the imaginary component of the first spectrum with that of the second spectrum, compute the inverse DFT of the resulting complex (fre- quency space) images and display the resulting images. Next, swap the magnitude of one DFT image with that of the other and compute (and display) the inverse DFT of the resulting complex images ( 20 pts ).
C) Load and display the following image and its DFT:
/usr/local/classes/cs/cs519/images/interfere.pgm
Determine where the high frequency spike(s) occurs in the image’s spectrum (preferably auto- matically, but manually with hard-coded positions will suffice) and scale the complex value at those positions such that its magnitude is the average magnitude of the 8 neighboring pixels (do not include the spike pixel when computing the average). (Remember that a spike corre- sponding to a sinusoid of a given frequency and direction has a negative or mirrored compo- nent). Compute the inverse DFT and redisplay the resulting image ( 20 pts ).
Write-up: Submit a write-up describing how you implemented this programming assignment and what you learned. What happens when you swap the imaginary components of two spectrum and then reconstruct the images? What about when the phases are swapped? Which compo- nent of the complex number (in terms of either real/imaginary or magnitude/phase) seems to dictate the amount of the various gray levels and which component controls the spatial posi- tioning information? Try computing and displaying the DFT of some of the following images: /usr/local/classes/cs/cs519/images/2d_gaussian.pgm /usr/local/classes/cs/cs519/images/2d_gausssd3.pgm /usr/local/classes/cs/cs519/images/2d_gausssd5.pgm /usr/local/classes/cs/cs519/images/2d_gausssd8.pgm /usr/local/classes/cs/cs519/images/2d_laplacesd5.pgm /usr/local/classes/cs/cs519/images/2d_white_box.pgm /usr/local/classes/cs/cs519/images/imagetest2.pgm /usr/local/classes/cs/cs519/images/imagetest3.pgm /usr/local/classes/cs/cs519/images/imagetest2.pgm /usr/local/classes/cs/cs519/images/tulip.pgm
What insights did you learn about the Fourier Transform by looking at the various spectra of some of these synthetic test images? What happened to the resulting image when you removed the high frequency spike in part C? As with the previous assignment, the write-up is to be turned in online as a separate submission (20 pts).