## CSC 249/449 Computer Vision: Fourier Filtering Assignment

Using the Fourier transform facilities in MatLab, (or Vista if you prefer) attempt to deblur an image using frequency-domain techniques. More specifically, by defocusing the lens of a camera, take one or more blurred images. Then, without changing the focus or aperture of the camera, take a picture of a point source of light in order to find the point-spread function (psf) of your camera/lens system. It may take some imagination to do this so that the image is neither over- nor under-exposed, contains no background, and so that the "point" has no structure of its own (i.e. is much smaller than the blur). An alternative to using the blurred point image values directly, is to use them to determine the parameters of an analytic model of the point spread function. For example, you might model the psf of a defocused lens as a uniform disk and use the image to determine its diameter. The advantage of this is you avoid problems with image noise and background. The disadvantage is that there might be important details of the actual psf that are not captured by the parameteric model you are using.

Another thing that is sometimes done is to de-blur an image degraded by camera movement. For this, you need to find the image of some small bright spot, which has left a track of the motion of the camera and which therefore represents the point spread function. This path has to be extracted from the image and used in an image restoration algorithm. An easier version would be just to pan the camera a small amount, which would give you a "streak" PSF. This is approximately the one-dimensional version of the pillbox PSF that is the ideal defocus blur PSF mentioned above.

Use this point-spread function to design a matched filter in the Fourier domain that will sharpen your blurred images. Remember that dividing by zero or anything close to it will give a result consisting of noise. You will have to experiment to find out what "close to zero" is (can you predict it analytically??) A lot of what high frequency energy there is in ordinary images is due to pixel noise, and you need to avoid amplifying it. How to fill in the blank areas (near the zeros of the transformed point spread function) is up to you. The quality of your result depends largely on how you do this and what you decide is "close to zero".

Hand in copies of your original and restored images, a picture of the point spread function and its power spectrum, and a careful writeup of what you did. It might be interesting to compare your results with a generic "sharpening" algorithm (such as the one in xv). You should be able to do at least as well as that.

Hints:

• Look at the power spectra of your transformed images to make sure they look right.

• Make sure your images are scaled correctly for viewing when you look at them.

• Since your point-spread function is likely symmetric (in fact circular) to a first approximation, you may be able to ignore the phase part of the transformed images and deal only with the power spectra (as long as you keep the phase of the original image for reconstruction)

• Don't underestimate how large "zero" may be. Remember, the values in the transform are obtained from weighted sums of all the pixels in the original image, with weights between +1 and -1. There may even be some advantage to making your "zero range" a function of frequency.

• One trick for getting at "zero" is taking the transform of one or more "blank" images (e.g. pictures of black or white scenes). Since such images contain noise typical of your overall setup, you can use them to estimate what the noise is in the Fourier domain, and hence what is distinguishable from zero.

• With only 8 bits per pixel, there is a limit to how much blurring you can undo. (Can you figure out how to predict analytically how much given the noise characteristics of your image?) If you can't seem to improve things much, try a smaller blur radius. You could also try to get more effective bits per pixel by taking multiple images and adding them up. This does not work quite as well as one might first guess - adding two 8-bit images does not give you a 9-bit image as far as noise is concerned, but the sqrt(n) increase in the signal-to-noise ratio does add up eventually. For example, with 16 independent images, the s/n ratio increases by a factor of sqrt(16) = 4, or two bits more than whatever you started with.
Section 4.4 in Sonka et al. (the text) has some information on image retoration that may be useful.