Sunday, August 8, 2010

Fourier Transform Model of Image Formation






In this activity, Fourier Transform was introduced. Fourier transform is a method of converting a certain object into the frequency space. In scilab, function as fft() and fft2() is used to discreetly transform a matrix into the fourier space. fft() means fast fourier transform. This algorithm has outputs interchanged. So, a certain fftshift() function is used to revert it to its original orientation.

Discreet FFT.
For familiarization of how fft() works, a certain 128x128 white circle with black background is subjected to fourier transforms.
Circle
after applying fft(), it looked like this:
FFT of Circle
using fftshift(), the image must revert to what is really the fft() of the figure
FFTshift of FFT of Circle
if another fft2() was applied to the newly transformed figure it will look like this:
Invers FFT of FFT of Circle

Using the letter A, it yielded these forms:

LetterA

FFT of LetterA
FFTshift of FFT ofLetterA
Inverse FFT of FFT of LetterA

It seems that if you inverse the fourier transform of the images, you will have the same image but inverted. :P

Convolution
Convolution of two images is like making the figure look like a little of both the two images. The convolution theorem is the multiplication of the fourier transform of the two images. Convolution is used in imaging devices, mostly in cameras. Usng this convolution method, an imaging device like a camera is simulated. The resulting image of the object to be taken and the aperture of the camera is simulated as follows:

Grayscale images of the word VIP and a white circle was convolved by obtaining the fft2() of the VIP image and the fftshift() of the circle. The two were multiplied and then the inverse fft() of the resulting product was obtained. Resulting images with varying circle size was seen as follows:


Initial Image of "VIP"Circle to simulate a small aperture

Circle to simulate a big aperture

Circle to simulate a medium sized aperture

Convolved images are as follows:

Convolution between the medium sized aperture and 'VIP'.

Convolution between the small sized aperture and 'VIP'
Convolution between the big sized aperture and 'VIP'

It can be seen that as the aperture gets bigger, a lot of light rays is allowed by the aperture. It results to a more defined structure of your resulting image. For a small aperture however, the image gets blurry due to the convolution of the circle and the image.

Correlation

Correlation measures up the degree of similarity between two function or images. For an even function, the correlation is the same as the convolution. That is why in this example, 128x128 pixel images were used.

In this part of the activity, template matching was done.This is a technique for finding the exactly identical patterns in a scene like finding a letter in a set of words.

128 x 128 images to be correlated.

This 128 by 128 pixel image with the caption 'THE RAIN IN SPAIN STAYS MAINLY IN THE PLAIN" and a 128 by 128 pixel images a the letter "A" with the same font size and style as in the previous image was used. The fourier transform of both images were obtained. The complex conjugate of text image and the fourier transform of A was multiplied. The inverse fourier transform of the resulting image was obtained. Resulting images was shown.

Correlated Images

Notice the bright spots? That is where A's are located. That's the first step in locating the patterns.

Edge detection

This is seen as the template mapping of an edge pattern with a template.
In this part, 3 patterns were used as the edge. They are as follows:

pattern1 = [-1 -1 -1; 2 2 2; -1 -1 -1];
pattern2 = [-1 2 -1; -1 2 -1; -1 2 -1];
pattern3 = [-1 -1 -1; -1 8 -1; -1 -1 -1];

with resulting images like this:


Pattern 1
Pattern 2
Pattern 3

After convolving them, It resulted these images:

Convolved VIP image with pattern 1
Convolved VIP image with pattern 2
Convolved VIP image with pattern 3

It seems that pattern3 has more matched sections of the image than other with respect to the number of bright sections seen in the image. It can also be sen that in pattern 2 an 1, there are black parts. They are somehow the resultant of the pattern and the section of the imaged that equaled to 0.

I think I'd give myself around 9/10 for this activity. Fourier transforms are cool.:)


No comments:

Post a Comment