example of a 2 dimensional fft
octave:13> x=[1 2 3 9; 8 5 1 2; 9 8 7 2] % this is an example of 2d array such as 3 * 4 pixels
x =
1 2 3 9
8 5 1 2
9 8 7 2
octave:14> Xc=fft(x); % fft of a 2d array does it down columns
octave:15> Xc=fft(x) % fft of a 2d array does it down columns
Xc =
18.0000 + 0.0000i 15.0000 + 0.0000i 11.0000 + 0.0000i 13.0000 + 0.0000i
-7.5000 + 0.8660i -4.5000 + 2.5981i -1.0000 + 5.1962i 7.0000 + 0.0000i
-7.5000 - 0.8660i -4.5000 - 2.5981i -1.0000 - 5.1962i 7.0000 + 0.0000i
octave:16> Xc=[fft(x(:,1)) fft(x(:,2)) fft(x(:,3)) fft(x(:,4))] % same as doing each column, so you can see that for example the first column of the result is the same as fft([1;8;9]).
Xc =
18.0000 + 0.0000i 15.0000 + 0.0000i 11.0000 + 0.0000i 13.0000 + 0.0000i
-7.5000 + 0.8660i -4.5000 + 2.5981i -1.0000 + 5.1962i 7.0000 + 0.0000i
-7.5000 - 0.8660i -4.5000 - 2.5981i -1.0000 - 5.1962i 7.0000 + 0.0000i
octave:17> X=(fft(Xc.').') % now to take the fft of the above: transpose, fft, untranspose, so that we take the fft across rows.
X =
57.0000 + 0.0000i 7.0000 - 2.0000i 1.0000 + 0.0000i 7.0000 + 2.0000i
-6.0000 + 8.6603i -3.9019 + 7.1699i -11.0000 + 3.4641i -9.0981 - 15.8301i
-6.0000 - 8.6603i -9.0981 + 15.8301i -11.0000 - 3.4641i -3.9019 - 7.1699i
octave:18> fft2(x) % that's the same as doing the 2d fft which is called fft2
ans =
57.0000 + 0.0000i 7.0000 - 2.0000i 1.0000 + 0.0000i 7.0000 + 2.0000i
-6.0000 + 8.6603i -3.9019 + 7.1699i -11.0000 + 3.4641i -9.0981 - 15.8301i
-6.0000 - 8.6603i -9.0981 + 15.8301i -11.0000 - 3.4641i -3.9019 - 7.1699i
%thus we see that the 2 dimensional fft (fft2) is just the fft across rows
%of the fft down columns, or vice versa.