*AP186 Lecture Notes, Maricor Soriano, 2008
We used the following code by Dr. Soriano in getting the FFT of a temporal signal. Fast Fourier Transform (FFT) is a DFT algorithm.
---
T = 2;
N = 256;
dt = T/N;
t = [0:dt:(N-1)*dt];
f = 5;
y = sin(2*%pi*f*t);
f1 = scf(1); subplot(2,1,1); plot(t,y); xtitle('sin 10*pi*t');
FY = fft(y);
F = 1/(2*dt);
df = 2*F/256;
f = [-(df*(N/2)):df:df*(N/2 -1)];
subplot(2,1,2); plot(f, fftshift(abs(FY))); xtitle('FFT');
---
The following plots show the FFT of a 1-D sinusoid. Observe that peaks on the FFT corresponds to the frequency of the sinusoidal function.
---
T = 2;
N = 256;
dt = T/N;
t = [0:dt:(N-1)*dt];
f = 5;
y = sin(2*%pi*f*t);
f1 = scf(1); subplot(2,1,1); plot(t,y); xtitle('sin 10*pi*t');
FY = fft(y);
F = 1/(2*dt);
df = 2*F/256;
f = [-(df*(N/2)):df:df*(N/2 -1)];
subplot(2,1,2); plot(f, fftshift(abs(FY))); xtitle('FFT');
---
The following plots show the FFT of a 1-D sinusoid. Observe that peaks on the FFT corresponds to the frequency of the sinusoidal function.
For images, which are two dimensional in nature, we use pixels as our discrete time. Therefore, FT of images is much like doing FT for temporal signals, only that now, we perform spatial FT rather than temporal FT. In SciLab and Matlab, a built-in function called fft2 is used for performing 2-D DFT.
In Mathworks the fft2 algorithm is defined as follows:
This is supported by the FT analyses of a sinusoidal function with dominant frequency equal to 5. I increased the number of samples from N=128, 256,512 and 1024.
In Mathworks the fft2 algorithm is defined as follows:
fft2(X) can be simply computed as
fft(fft(X).').'
This computes the one-dimensional DFT of each column X, then of each row of the result.
This is supported by the FT analyses of a sinusoidal function with dominant frequency equal to 5. I increased the number of samples from N=128, 256,512 and 1024.
No comments:
Post a Comment