Activity 6: Fourier Transform Model of Image

July 8, 2008 at 11:15 am (Uncategorized) (, , , , )

Activity 6-A: Familiarization with discrete FT

Doing the Fourier transform on a circle :

yields

However, the FFT algorithm inverts the quadrants of the FT plane and this has to be corrected using the fftshift() command. This process yields the correct FT of a circle whose analytical solution is the Airy circle, as shown in the figure below

Performing an FFT on th FFT of an image results to the original image, and is one of the properties of FFT. The image below indeed confirms this.

I = imread(‘circle.bmp’);
Igray = im2gray(I);
FIgray = fft2(Igray); //remember, FIgray is complex
h=scf(1);
imshow(abs((FIgray)), []); xset(“colormap”, hotcolormap(64));
h=scf(2);
imshow(abs(fftshift(FIgray)),[]); xset(“colormap”, hotcolormap(64));
h=scf(3);
imshow(abs(fft2(FIgray)), []); xset(“colormap”, hotcolormap(64));

-oOo-

Convolution

Convolution is process wherein the product of two functions f and g has the effect of transforming f and g.

Also, the convolution theorem states that the Fourier transform of a convolution is the product of the individual Fourier transform times a constant k.

In optics, this concept can be applied to lenses wherein we have an original image f and a lens g. Thus, with a finite lens, we can never reconstruct an image 100%.

We obtain the FT of the letter J and obtained

After fftshift, we had

And doing an fft again results to an inverted J.

We now convolve the image with a circular aperture and this results to:

We can see that the image has been blurred because of the finite size of the aperture. We then investigate the effect of varying the lens/aperture size with the resulting image. From our simulations, we saw that decreasing the size of the lens decreases the clarity of the image, as show in the following figure.

clear all;
r=imread(‘smallest.bmp’);
a=imread(‘letters.bmp’);
rgray = im2gray(r);
agray = im2gray(a);
Fr = fftshift(rgray);
Fa = fft2(agray);

FRA = Fr.*(Fa);
IRA = fft2(FRA); //inverse FFT
FImage = abs(IRA);
h=scf(1);
imshow(FImage, []);

-oOo-

Template Matching

We performed template matching of the images. From the text below, we located areas where they have a high degree of correlation and similarity with the template “A”. There is a high degree of correlation in places where there is high degree of similarity.

Places with high correlation is indicated by bright white spots. However, the image is upside-down and left-side right. Rotating the image of the correlation would correspond would yield a direct correspondence with the places in the original text.

words=imread(“word.bmp”);
a=imread(“A.bmp”);
words=im2gray(words);
a=im2gray(a);
ftwords=fft2(words);
fta=fft2(a);
correlation=ifft(fta.*conj(ftwords));
imshow(abs(fftshift(correlation)), []); xset(“colormap”, hotcolormap(256);

-oOo-

Edge Detection

We performed edge-detection using vertical, and horizontal filters using the command imcorrcoef(). This command is similar to template matching but instead uses a kernel template, and doesn’t care with the size of the template and the image.

let=imread(“L.bmp”);
let=im2gray(let);
hor = [-1 -1 -1; 2 2 2; -1 -1 -1];
vert= [-1  2 -1; -1 2 -1;-1  2 -1];
von = [-1 -1 -1; -1 8 -1; -1 -1 -1];
pattern=von //im2gray(vert);
c=imcorrcoef(let, pattern);
imshow(c);

We can see from the figure above that the correlation technique is helpful in finding the horizontal and vertical edges of the letter L. But we want to get the outline of an image, we can use the “von” pattern located above that locates only boundaries may it be horizontal or vertical.

Rating: 9.5 because i wasn’t reading some of the instruction although i was able to perform all the required tasks.

Acknowledgments: Julie, Cole, Benj and Lei.

Leave a comment