Monday, July 26, 2010

A7 - Properties of the 2D Fourier Transform

The journey of mastering Fourier Transform continues...

7.A Familiarization with FT of different 2D patterns

In this part of the activity we applied FT to some 2D patterns, namely: square, donut, annular square, slits and two dots. These FTs will be very handy in the next activities so be sure to remember them...



(a) - (b)
Figure 1: Square pattern (a), FT (b)

- The FT of a square looks like a diffraction pattern with the brightest spot at the center. The intensity is constantly decreasing as the pattern becomes farther from the center.


(a) - (b)
Figure 2: Annular 2D pattern (a), FT (b)

- The FT of an annular pattern is an Airy disk having amplitude not constantly decreasing as it becomes farther from the center. This is due to the presence of the annulus within the circle. Its FT interferes with that of the FT of the circle taken alone.


(a) - (b)
Figure 3: Square annulus pattern (a), FT (b)

- The FT is more or less similar to the FT of the square earlier. The only difference is that just like in the FT of a donut, the FT of the annulus inside interferes with that of the square alone. the result is an uneven distribution of intensity as you move farther away from the center -not constantly decreasing.


(a) - (b)
Figure 4: 2 slits symmetric along the x-axis (a), FT (b)

- I feel like I don't have to explain this figure anymore... :) From what we have learned from our earlier physics, the pattern produced when you shine light to two slits is an interference pattern. Suppose you have an experiment, let's say Young's double slit experiment, you can find the actual frequencies by just taking the FT of the sinusoidal pattern that you obtain.



(a)-(b)
Figure 5: 2 dots (a) FT (b)

- The FT of two slits symmetric about the x-axis looks a lot like a magnified airy pattern but multiply with a periodic pattern.

7.B: Anamorphic property of the Fourier Transform

all about SINES



(a) - (b)
Figure 6: Sinusoidal pattern along the y-axis (a), FT (b)

- The FT of a sine pattern along the y-axis are two dirac deltas also symmetric along the y-axis.


The following figure will show you how the FT of a sinusoid pattern changes if you...

...Change the frequency:


Figure 7: FTs with varying frequency: 2, 4, 8, 10 respectively

...add a constant bias:

(a) - (b)
Figure 8: sine with a bias (a), FT (b)
...rotate the sine pattern:


(a) - (b)
Figure 9: rotated sine pattern (a), FT(b)

...add two sines(one symmetric along the x-axis and one symmetric along the y-axis):
looks like an egg carton right? :D

(a) - (b)
Figure 10: egg carton pattern (a), FT (b)

...add several rotated sines:


(a) - (b)
Figure 10: sum of several rotated sine patterns (a), FT (b)

- my prediction on this part of the activity is that pair-by-pair dirac deltas will arise along the direction of their respective sine pattern.


CODE:
/////////////////////////////////////////////////
//7.A

a = im2gray(imread('C:\Users\cindyleen\Desktop\square.bmp'));
b = im2gray(imread('C:\Users\cindyleen\Desktop\squarea.bmp'));
c = im2gray(imread('C:\Users\cindyleen\Desktop\circlea.bmp'));
d = im2gray(imread('C:\Users\cindyleen\Desktop\slits.bmp'));
e = im2gray(imread('C:\Users\cindyleen\Desktop\dots.bmp'));

afft = fftshift(abs(fft2(a)));
scf();
imshow(afft, []);
afftn = (afft - min(afft))/(max(afft) - min(afft));
imwrite(afftn, 'C:\Users\cindyleen\Desktop\fftsquaren.bmp');

bfft = fftshift(abs(fft2(b)));
scf();
imshow(bfft, []);
bfftn = (bfft - min(bfft))/(max(bfft) - min(bfft));
imwrite(bfftn, 'C:\Users\cindyleen\Desktop\fftsquarean.bmp');

cfft = fftshift(abs(fft2(c)));
scf();
imshow(cfft, []);
cfftn = (cfft - min(cfft))/(max(cfft) - min(cfft));
imwrite(cfftn, 'C:\Users\cindyleen\Desktop\fftcirclean.bmp');

dfft = fftshift(abs(fft2(d)));
scf();
imshow(dfft, []);
dfftn = (dfft - min(dfft))/(max(dfft) - min(dfft));
imwrite(dfftn, 'C:\Users\cindyleen\Desktop\fftslitsn.bmp');

efft = fftshift(abs(fft2(e)));
scf();
imshow(efft, []);
efftn = (efft - min(efft))/(max(efft) - min(efft));
imwrite(efftn, 'C:\Users\cindyleen\Desktop\fftdotsn.bmp');

//////////////////////////////////////////////////////////////

//7.B
//1.
nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4 //frequency – you may change this later.
z = sin(2*%pi*f*X);
zn = (z - min(z))/(max(z) - min(z));
imshow(zn,[]);
imwrite(zn, 'C:\Users\cindyleen\Desktop\sine4.bmp');

fftsine = fftshift(abs(fft(z)));
scf();
imshow(fftsine, []);
fftsinen = (fftsine - min(fftsine))/(max(fftsine) - min(fftsine));
imwrite(fftsinen, 'C:\Users\cindyleen\Desktop\fftsine6n.bmp');

//4.
nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f1 = 4 //frequency – you may change this later.
f2 = 3
z = sin(2*%pi*f1*X) + cos(2*%pi*f2*X);
zn = (z - min(z))/(max(z) - min(z));
imshow(zn,[]);
imwrite(zn, 'C:\Users\cindyleen\Desktop\sineandbias.bmp');


fftsine = fftshift(abs(fft(z)));
scf();
imshow(fftsine, []);
fftsinen = (fftsine - min(fftsine))/(max(fftsine) - min(fftsine));
imwrite(fftsinen, 'C:\Users\cindyleen\Desktop\fftsinebias3n.bmp');

//5.
nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4 //frequency – you may change this later.
theta = 30;
z = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));
zn = (z - min(z))/(max(z) - min(z));
imshow(zn,[]);
imwrite(zn, 'C:\Users\cindyleen\Desktop\siner.bmp');

fftsiner = fftshift(abs(fft(z)));
fftsinern = (fftsiner - min(fftsiner))/(max(fftsiner) - min(fftsiner));
imshow(fftsinern, []);
imwrite(fftsinern, 'C:\Users\cindyleen\Desktop\fftsinern.bmp');

//6.
nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4 //frequency – you may change this later.
z = sin(2*%pi*4*X).*sin(2*%pi*4*Y);
imshow(z,[]);
zn = (z - min(z))/(max(z) - min(z));
imwrite(zn, 'C:\Users\cindyleen\Desktop\eggcarton.bmp');

fftsinexy = fftshift(abs(fft(z)));
fftsinexyn = (fftsinexy - min(fftsinexy))/(max(fftsinexy) - min(fftsinexy));
scf(); imshow(fftsinexyn, []);
imwrite(fftsinexyn, 'C:\Users\cindyleen\Desktop\fftsinexyn.bmp');

//7.
nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4 //frequency – you may change this later.
theta = 30;
z = sin(2*%pi*4*X).*sin(2*%pi*4*Y).*sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));
zn = (z - min(z))/(max(z) - min(z));
imshow(zn , []);
imwrite(zn, 'C:\Users\cindyleen\Desktop\sinexyr30.bmp');

fftsinexyr = fftshift(abs(fft(z)));
scf();
imshow(fftsinexyr, []);
fftsinexyrn = (fftsinexyr - min(fftsinexyr))/(max(fftsinexyr) - min(fftsinexyr));
imwrite(fftsinexyrn, 'C:\Users\cindyleen\Desktop\fftsinexyrn2.bmp');


I want to give myself a grade of 10 for this activity.

Arigato Joseph!!! :D

No comments:

Post a Comment