Tuesday, July 7, 2009

Activity 5 | Fourier Transform Model of Image Formation

The Fourier Transform is one of the basic transforms used in imaging and is implemented in a fast and efficient way by the Fast Fourier Transform or FFT which is also mainly used in signal processing. The FFT is available in many signal and image processing software like the one used in this activity which is Scilab. The fft2() function in Scilab performs the Fast Fourier Transform for any two-dimensional signal or for this activity, images. Analyzing and processing images is explored using the the Fast Fourier Transform, convolution used in edge detection and correlation used in template matching.

5A - Familiarization with Discrete FFT

In the first part of the activity we get to familiarize the built-in function fft2() by applying it to a 128x128 image of a white circle on black background and the letter A that is constructed using Paint. Then we apply fftshift() to get the Fourier Transform of the image. The Fourier Transforms obtained agree with the analytical Fourier Transform of a circle which is an airy disk that becomes a airy point when the circle is large while for the letter A, it is like the Fourier Transform of a triangle that has three lines crossing each other at the center.

If we take the FFT of the resulting FFT of the images we get the intensity image or the original image that is inverted as shown by the last row of images. What is expected after getting the Fourier transform of the Fourier transform of the original image is the original image itself but inverted since an fftshift() is applied after the first FFT.



Original
image
FFT of
image
Shifted
FFT image
FFT of
FFT of
image


5B - Simulation of an Imaging Device

In this activity we simulate an imaging device - the lens - by using FFT and convolution where a function is operated on another function to get a new function. The object is a 128x128 image of the letters VIP in Arial which will serve as the first function and the aperture of the lens is a 128x128 image of a circle and its transfer function will be the second function. The convolution of these two functions will give the image produced by this system. The Fourier Transform is the lens in this system such that by doing a convolution between the Fourier Transforms of the object and the aperture you get the produced image of the system. Below are the images used and produced in this activity.


Different sizes of aperture are used as shown by the different sizes of circle images. It can be seen that as the aperture size becomes larger, the produced image becomes clearer and more defined. This agrees with the fact that small, finite apertures can't get or capture all light coming from the object thus a blurring is observed in the resulting image.

5C - Template Matching Using Correlation

Another method used in signal and image processing is correlation that is similar to convolution such that it is also related to the complex conjugation of the Fourier Transforms of the desired signals. Correlation measures the degree of similarity between two signals thus making it useful for checking patterns like for this activity where an image containing a phrase is correlated with another image containing the letter A. This letter A will be the template or the pattern.


The resulting image after the correlation shows the highest values, with black=0 and white=1, are at areas where the letter A can be found.

5D - Edge Detection Using the Convolution Integral

Edge detection is also like template matching only a pattern is used and that pattern is convolved with the VIP image using the built-in function imcorrcoef() in Scilab SIP Toolbox. Below are the resulting images using different patterns such as vertical, horizontal, diagonal, back diagonal, and spot pattern.

The images at the right side show the areas that are highly similar to the respective pattern. Say for example for the vertical and horizontal patterns, in the resulting image, the most pronounced areas are the edges that are vertical and horizontal respectively. The horizontal and vertical lines especially in the letters I and P are gone respectively for the vertical and horizontal pattern. Lastly, among the five patterns used, the spot pattern is the one that gave the best edge detection since it does not suggest any specific direction and it is like tracing the edge pixels of the letters V, I, and P.

I'd like to give myself a grade of 10 for this activity because it was fairly easy since the codes are already given but I give myself a grade of 9 for this activity because I did not finish the blog on time. Also I had a hard time exporting quality images from my results since I did not know anything about the command imwrite() but I thank Mr. Miguel Sison for mentioning it so I was able to apply it to the last part of the activity. It is a lot easier and the image quality is better.

Reference - UPNIP - AP186 - Activity Sheet 5 - Fourier Transform of Image Model.

No comments:

Post a Comment