Tuesday, July 12, 2011

six

I would like to apologize for the totem pole approach I took in presenting my images.  Neither Blogger nor Windows Live Writer 2011 (which I still love by the way) were kind to me for this activity.

I always thought Fourier Transforms were just for numbers.  Here, I am obviously proven wrong.  From the mathematical expression (Figure 1), Cooley and Tukey were able to create the Fast Fourier Transform Algorithm or FFT – a fast and efficient Fourier Transform implementation.  Because of my other Physics subjects and exposure to various topics in our research group.  I’ve always wondered where the ‘2’ from fft2() came from and I now know that thus kind of FFT algorithm is for 2-dimensional signals.

eq_fft
Figure 1. Mathematical expression of the Fourier Transform

Before we were introduced to the more complicated side of the FFT algorithm, we were first tasked to familiarize ourselves with the algorithm itself.  This was done with images of a circle and the letter ‘A’ and variations of the FFT algorithm.

a_circlea_circle_1_ffta_circle_2_fta_circle_3_fft_of_fft
Figure 2. (Top to Bottom) Original circle image, result of using fft2() on circle image and using fftshift() and fft2() on top right image.

a_lettera_letter_1_ffta_letter_2_fta_letter_3_fft_of_fft
Figure 3. (Top to Bottom) Original letter image, result of using fft2() on letter image and using fftshift() and fft2() on top right image.

I forgot to mention it earlier but the output of the fft2() has interchanged the quadrants along the diagonal.  The fftshift() function simply places these quadrants in their proper place.  In relation to this, it seems both the second and third images of Figures 2 and 3 show this phenomena.  Another equally surprising thing is that the last image of Figure 3 is a vertically-flipped version of the original image.  Note that the results from both the fft2() and fftshift() are complex number arrays and hence the images that you see above are the absolute value of these arrays.  Another way of looking at it is that the images you see above are the amplitudes of these transforms.

From what I figure, Convolution it is a measure of how similar two functions (or in this case, images) are.  With this, we can simulate imaging systems as what was done with an object (VIP) and apertures of different pixel radii (6, 12, 18, 28 and 42).

b_vipb_aperture_r_06b_aperture_r_12b_aperture_r_18b_aperture_r_28b_aperture_r_42
Figure 4. (Top to Bottom) Object and apertures of radius 6, 12, 18, 28 and 42.
  
b_vip_aperture_06b_vip_aperture_12b_vip_aperture_18b_vip_aperture_28b_vip_aperture_42
Figure 5. (Top to Bottom) Resulting images from convolution with apertures of radii 6, 12, 18, 28 and 42.

As you can see, the images become clearer with larger aperture sizes – consistent with the theories behind diffraction.  I can also infer that the apertures used were converging lenses due to the inverted orientation of the images compared to the object.

Next, template matching using correlation was used.  Here, we more or less compare a sentence and the letter ‘A’ that have the same font size and color.  As you can see from the resulting image, greater intensities can be seen where the letter ‘A’ is roughly located in the sentence file.

c_letterc_sentencec_template_matching
Figure 6. (Top to Bottom) The letter ‘A’, sentence and their resulting correlation.

Can we only correlate sentences and texts then?  Of course not.  The correlations of an object (VIP) and different patterns (horizontal, vertical, diagonal and spot)  were obtained.  I have to note that these results somehow remind me of the effects of a few Image Filters in Photoshop.

d_vipd_vip_horizontald_vip_verticald_vip_diagonald_vip_spot
Figure 7. Resulting images from the correlation of the object with a (top left) horizontal, (top right), vertical, (bottom left) diagonal and (bottom right) spot pattern.

In terms of edge detection though, the correlation with the spot pattern wins.  The other three – especially the correlation with a vertical pattern – just look like fancily processed text.

The task that was given to us, at first, seems gargantuan but it didn’t turn out that way.  The codes were already given to us and all we had to do were create the images for processing.  Yes, I went overboard with my OCD (mostly) and tried to ensure that my circles were indeed circles and all my letters, words, etc. were positioned in the middle of the image.  Despite this absence of effort on my part, I think I deserve a grade of 10 anyways.

SUPPLEMENTARY INFORMATION

For archiving purposes – or basically if you’re just curious – here are the codes I used for this activity.  You may notice I removed the first three lines simply because these lines of code were used to change the directory and the stacksize.

code a
Figure S1. The code used for the familiarization with the FFT algorithm.

code b
Figure S2. The code used for the investigation of convolution or the simulation of an imaging device using Fourier Transforms.

code c
Figure S3. The code used for the investigation of correlation using Fourier Transforms.

code d
Figure S4. The code used for the edge detection using the convolution integral.

REFERENCES

Activity 6 – Fourier Transform Model of Image Formation, Applied Physics 186 Manual

No comments:

Post a Comment