Monday, July 7, 2008

Fourier Transform Model of Image Formation

July 8, 2008

In this activity, we try to get the Fourier transform of an image.

A. Familiarization

The images are created in Paint. Programs are run in Scilab. First, we investigate a circle such as the one below. The input image size is 128 x 128.


Performing the built-in Fast Fourier transform (FFT) algorithm in Scilab on it, we get quadrants of concentric circles positioned in the corner of the FFT image.



We shift the FFT so that it is symmetric about the origin.
We obtain the Airy disk.





Next, we render the Airy disk in Scilab's hotcolormap, which is composed of shades of red and yellow.
B. Simulation of an Imaging Device

Now, suppose we have a camera which has a lens aperture. Upon passing through the aperture, the signals from this object are distorted or convoluted. Convolution of two functions f and g, representing the object and the aperture respectively, is equivalent to multiplying element-per-element their Fourier transforms, and getting the Fourier transform of their product. The resulting is what we see when the image forms at the back of the lens.

For example, we have this object below.


Its Fourier transform is,




The aperture is already in Fourier space, so we multiply it with VIP's FFT. Then, we get the FFT again. The result is a blurred mirror reflection, with visible fringes, of the object.










When we replace the lens with a larger one, the object is better resolved. Meanwhile, shifting to a smaller lens distorts the image more. This must be because the zero-order of the Airy disk broadens as the aperture gets smaller, thus causing more distortion.



































C. Template Matching Using Correlation


We also tried the application of the Fourier transform in Template Matching.
We have on the left side the input image, and below it the pattern we want to trace. Using the following code, to track down A, an inverted and blurred image of the input is retrieved. Notice the locations of the bright spots. They correspond to the positions of A in the input.




m = imread('C:\Documents and Settings\instru\Desktop\ap186(2)\fig11.bmp');
k = imread('C:\Documents and Settings\instru\Desktop\ap186(2)\fig12.bmp');
mgray = im2gray(m);
kgray = im2gray(k);
M = fft2(mgray);



K = fft2(kgray);
MK = M.*conj(K);
invMK2 = fft2(MK);

invMK2 = fftshift(invMK2);
imshow(abs(invMK2),[]);












D. Edge Detection

Let's go back to VIP. Now our aim is to detect the horizontal (top image) and vertical edges (bottom image).



m = imread('C:\Documents and Settings\instru\Desktop\ap186(2)\fig5.bmp');
k = [-1 2 -1; -1 2 -1; -1 2 -1];
mgray = im2gray(m);
l = imcorrcoef(mgray,k);
imshow(abs(l),[]);




















SELF -EVALUATION: 10/10.
FFT is amazing, especially in edge detection.



Reference:
[1] Dr. Soriano's lecture notes

No comments: