## CS/ECE 545 Homework 5

Complete by Class 7

DFT

In the following problems, if you did not get your DFT program to work, you may use this one, with appropriate changes. Files are (in addition to the usual img.c and img.h):
• cimg.h -- complex and double precision image structures and function prototypes
• complex.c -- complex and double image manipulation functions
• dft.c -- the DFT itself. THere is a bit of "junk" used during debugging included in this. Note that it takes 4 files names: The input file, a file to write the DFT magnitude, a file to write hte log DFT magnitude, and a file to write the real part of the IDFT of the DFT. This last file should equal the input file (useful for debugging).

Filtering

Use your DFT program to perform ideal low-pass filtering. The ideal low-pass filter is parameterized by a cutoff frequency, call it w. The ideal low-pass filter has a response of 1 when the input frequency is less than some input parameter w. In particular, we require that u2 + v2w2.

Compute the Fourier Trannforms of your test images and set to zero those components outside the passband. Then transform back to spatial coordinates to view. As before, you may find it convenient to multiply by (-1)x + y to shift the transform to the middle of the image.

Test your program on the moon and (if you have the processing time) telescope images using various cutoff frequencies. There are two versions of the moon image: `moon1` is a 256x256 image and `moon2` is a 64x64 version. Discrete Fourier Transforms can be quite computationally intensive so you may find it more convenient to use the second image.

You can find them here:
moon1.img, moon1.tif, moon1.gif
moon2.img, moon2.tif, moon2.gif
telescope.img, telescope.tif, telescope.gif,

Noise

Write a program to add white gaussian noise to an image. The noise standard deviation s should be input as a parameter. If you are wondering how to generate gaussian random variables, a sufficiently good approximation for our purposes is to add 3 samples from a uniform distribution. That is, generate and add 3 random numbers from 0 to X. The mean of the sum will be 3X/2 and the variance will be X2/4. Normalize the sum make a zero-mean random variable with standard deviation s.

What happens if you try to bandpass filter the noisy image? Try it.

Convolution

Problem 5.21. Hint: You may find it much, much easier to start with H(u,v) and derive h(r).

What to hand in
Hand in to class

• Your filtering program, including enough comments so we can understand what you have done, with examples.
• The Gaussian noise program, with examples, and the answer to the question.
• Answer to the convolution problem.

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