clear all;close all;clc;
Image = imread("aerial.tiff");
f = double(Image) ;
%2D DFT
F1 = fft2(f);
M=size(f,1);
N=size(f,2);
for i = 1:N
F2(i,:) = fft(f(i,:));
end
答案 0 :(得分:1)
在MATLAB documentation中,fft2
定义为:
fft
在列上,然后是fft
在行上。 此外,如果您打开fft2
代码,则会发现:
f = fft(fft(x,[],2),[],1);
此代码可以为您提供帮助:
clear;close all;clc;
Image = phantom(256);
f = double(Image);
%2D DFT
F1 = fft2(f);
M=size(f,1);
N=size(f,2);
% 2D FFT by twice 1D FFT
F2 = fft(fft(f,[],2),[],1);
% Difference between the results
diff = F2 - F1;
[min(min(diff)) max(max(diff))]
subplot(1,2,1)
imshow(30.*log(abs(fftshift(F1)) + 1),[])
title('FFT using fft2')
subplot(1,2,2)
imshow(30.*log(abs(fftshift(F2)) + 1),[])
title('FFT using fft twice')