Tuesday, July 7, 2009

ACTIVITY 5 Fourier Transform Model of Image Formation


Programming Language: Scilab 4.1.2

6.A Familiarization with Discrete FFT


This part of the activity allows us to visualize the basic meaning of the fundamental functions of Fourier transform greatly needed in image formation and image processing. The first function we tried is fft(). The information embedded in an image is in the spatial domain. By applying fft() on the image, we are transforming the image information into the frequency domain (see FFT of Figures 1 and 2). However, the Fourier transform of an image is not much of a help also in understanding the information encoded in the image. The second function we tried is fftshift(). It rearranges the fft output in such a way that the zero-frequency component of the spectrum is shifted at the center (see FFTSHIFT of Figures 1 and 2). For the circle, the resulting image resembles the Airy disk or pattern which is the analytic Fourier transform of circles. In the case of letter A, the resulting image is the combination of the Fourier transforms of the vertical diagonal lines and a horizontal line that form the letter, i.e. two intersecting horizontal diagonal lines and a vertical line, respectively. This is in accordance to the distributive property of Fourier transform. As an additional exercise, we also tried applying the ff() function twice on the image (see FFT of FFT of Figures 1 and 2). The resulting image is the inverted form of the original image. This can be explained by recalling the duality property of Fourier transforms, i.e. FT of FT of f(x) = f(-x). The inversion is not evident in the circle since it is symmetric in all directions. The visualization of applying fft() twice is more obvious in letter A, which is inverted along the horizontal axis. So, again, applying the function fft() twice does not give you back the original image. If you want to get the original image, you must use the ifft() function or the inverse Fourier transform.

Figure 1. click on the image for a better view

Figure 2. click on the image for a better view

6.B Simulation of an Imaging Device

Simulation of an imaging device is similar to getting the convolution of two functions or the product of the Fourier transform of the two functions. It is also the same as "smearing" of one function against the other such that the resulting function looks similar to both functions. In the case of an imaging device, the resulting image would be how the device detects the object being viewed. For this activity, our object is the word VIP and our imaging device is the circular aperture representing a cicular lens of finite radius. Finite radius means the lens can only detect a limited number of light rays reflected off the object resulting into an image that is never 100% similar to the actual object. The resulting image is dependent on the radius of the circle as shown in Figure 3. For very small circles, the resulting image is distorted and cannot be read. This is because the light rays allowed by the lens to pass is not enough to reconstruct the word VIP. As the circle gets bigger, the resulting image becomes more like the original image. As you can see in Figure 3, the reconstructed VIP word is still gray when the medium-sized circle is used. It becomes whiter and the edges are more defined when the larger circle is used. This just means that the lens is able to collect more light rays enough to reconstruct the word VIP. The variation in the radius of the lens is reflected in the varying color of the reconstructed word from gray to white.

Figure 3. click on the image for a better view

6.C Template Matching Using Correlation

Our goal for this part is to count the number of A's in the text "THE RAIN IN SPAIN STAYS MAINLY IN SPAIN". We did this by getting the correlation between the two images containing the text and a letter A made using Microsoft Paint. It must be noted that the text and A must be of the same font size to be able to successfully correlate the two images. As mentioned in the manual, the correlation of the two functions representing the images measures their degree of similarity. The more identical the two images are on the same position, the higher their correlation value is. High correlation values are represented by very bright dots in the resulting image (see MATCHED in Figure 4). The mesh plot of the image supports this also. There are 5 bight dots in MATCHED and 5 spikes in the mesh plot, which means there are 5 A's in the text. We also manually counted 5 A's in the text Hence, the code we created can be used for template matching. It is also mentioned in the manual that correlation is related to convolution and if at least one of the functions is even, the correlation is just equal to the convolution. If the A, which is symmetrical, is located at the center of the image, then the function representing it would be even. It means the correlation would just be equal to the convolution of the images.

Figure 4. click on the image for a better view

6.D Edge Detection Using the Convolution Integral

We were able to successfully detect the edges of the word VIP depending on the orientation of the black portions in the leftmost images (see Figure 5). If it they are oriented horizontally (vertically), then only the horizontal (vertical) lines in the edges will be detected. In the case of the All Around, all edges are detected since it contains both horizontal and vertical orientations. The diagonal lines in the edges may also be detected since they have components in both orientations (horizontal and vertical).

Figure 5. click on the image for a better view

I was able to successfully generate the necessary images for this activity but I was not able to finish it before deadline, so I would just myself a grade of 9 for this activity. I would like to thank Mr. Luis Buno III, Mr. Jaya Combinido and Ms. Kaye Vergel for answering some of my questions. I would also like to thank Prof. Maricor Soriano for her suggestion about mesh plot in part C.


References:
1. Activity 5 Manual
2. http://www.dspguide.com/ch24/5.htm
3. http://www.insight-journal.org/browse/publication/125
4. http://www.scilab.org/product/man/fftshift.html
5. Integral Transforms and Applications by Lokenath Debnath







No comments:

Post a Comment