Saturday, September 18, 2010

Activity 7 - Properties of the 2D Fourier Transform

In the first part of the activity, (a) different 2D patterns were created and their (b) fourier transforms were taken (see Figure 1-5).



(a)

(b)

Figure 1.A 128x128 px white square



(a)

(b)

Figure 2. A circular annulus with inner radius 32 px and outer radius 64 px



(a)

(b)

Figure 3. A square annulus with inner square side of 64 px and outer square side of 128 px.



(a)

(b)

Figure 4. Two horizontal slits 128 pixels apart.



(a)

(b)

Figure 5. Two dots horizontally aligned and 128 pixels apart.




For the analysis of the anamorphic property of the Fourier Transform, 2D sinusoids were created in Scilab. Figure 6 shows sinusoids with varying frequencies and their corresponding Fourier transforms. Also, images of the FT modulus are shown with a constant bias added to the original sinusoids. This addition of constant is for simulating real images, that is, digital images with no negative values. It has been observed that as the frequency increases, the distance between the peaks increases also. Also, when the bias was added, a peak at f=0 appeared.



Figure 6. Horizontal sinusoids [z = sin(2*%pi*f*X)] with frequency (a) f = 2, (b) f = 4,

(c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.



In Figure 7 and Figure 8, rotating the sinusoid by 30 degrees resulted to the rotation of the line containing the two peak frequencies.


Figure 7. 30-degree rotated sinusoids [z = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)))] with frequency

(a) f = 2, (b) f = 4, (c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.



Figure 8. 45-degree rotated sinusoids [z = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)))] with frequency

(a) f = 2, (b) f = 4, (c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.



Figure 9 shows sinusoids that resulted from the product of two corrugated roofs, one running in the x-direction and the other in y-direction.


Figure 9. corrugated roofs or sinusoids [z = sin(2*%pi*f*X).*sin(2*%pi*f*Y)] with frequency

(a) f = 2, (b) f = 4, (c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.



Figure 10 and 11 show what happened when rotated sinusoids were added to the sinusoids in Figure 9. Ans as expected, as the frequency increases, distance between peaks increases and also, a rotation of the line connecting the peaks of the rotated sinusoids resulted.


Figure 10. 30-degree rotated sinusoids added to sinusoids in Figure 9

[z = sin(2*%pi*f*X).*sin(2*%pi*f*Y) + sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)))]

with frequency (a) f = 2, (b) f = 4, (c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.


Figure 11. 45-degree rotated sinusoids added to sinusoids in Figure 9

[z = sin(2*%pi*f*X).*sin(2*%pi*f*Y) + sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)))]

with frequency (a) f = 2, (b) f = 4, (c) f = 8, (d) f = 16 and (e) f = 32.

Second and third rows display the FT modulus of the sinusoids and biased sinusoids.




The following code was used to create the images above.

//Activity 7.B Anamorphic property of the Fourier Transform

nx = 100; ny = 100;

x = linspace(-1,1,nx);

y = linspace(-1,1,ny);

[X,Y] = ndgrid(x,y);

name = 'sinusoid';

for f = [2 4 8 16 32] //frequency

k = 'a_';

z = sin(2*%pi*f*X);

//theta = 45;

//z = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));

//z = sin(2*%pi*f*X).*sin(2*%pi*f*Y);

//z = sin(2*%pi*f*X).*sin(2*%pi*f*Y) + sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));

//z = sin(2*%pi*f*X).*sin(2*%pi*f*Y) + sin(2*%pi*2*3*f*X).*sin(2*%pi*2*3*f*Y);

//scf(); imshow(z,[]);


Im = z;

Im = (Im - min(Im))/(max(Im)-min(Im));

imwrite(Im, strcat([PATH,k,name,string(f),'.bmp']));

output = abs(fftshift(fft2(z)));

Im = output;

Im = (Im - min(Im))/(max(Im)-min(Im));

imwrite(Im, strcat([PATH,k,'fft_',name,string(f),'.bmp']));


//bias

z2 = z + abs(min(z));

Im = z2;

Im = (Im - min(Im))/(max(Im)-min(Im));

imwrite(Im, strcat([PATH,k,name,'_bias_',string(f),'.bmp']));

output = abs(fftshift(fft2(z2)));

Im = output;

Im = (Im - min(Im))/(max(Im)-min(Im));

imwrite(Im, strcat([PATH,k,'fft_',name,'_bias_',string(f),'.bmp']));

end

Reference:

[1] M.N. Soriano, "Applied Physics 186 - Properties of the 2D Fourier Transform", 2010.


Credits:
Self Evaluation:

No comments:

Post a Comment