【发布时间】:2011-09-17 14:33:39
【问题描述】:
傅立叶变换F的幅值和相位定义为:
Mag = sqrt(Real(F)^2 + Imaginary(F)^2)
和
Phase = arctan(Imaginary(F)/Real(F))
我尝试编写 matlab 代码,该代码接收灰度图像矩阵,对矩阵执行 fft2(),然后根据变换计算幅度和相位。然后我希望计算傅立叶变换的虚部和实部。这是通过将前两个方程重新排列为:
Real = Mag/sqrt(1 + tan(Phase)^2)
和
Imaginary = Real*tan(Phase)
最后合并和逆fft2:
F = Real + i*Imaginary
image = ifft2(F)
我希望看到与输入相同的图像,但我得到了垃圾。我的数学错了吗?我的matlab mfile代码如下:
function y = forwardBackwardFFT(image)
F = fft2(image);
mag = sqrt(real(F).^2 + imag(F).^2);
phase = atan(imag(F)./real(F));
re = sqrt((mag.^2)./(1 + tan(phase).^2));
im = re.*tan(phase);
F = re + i*im;
f = ifft2(F);
subplot(1,2,1);
imshow(image);
Title('Original Image');
subplot(1,2,2);
imshow(f);
Title('Image after forward and backward FFT');
y = f;
非常感谢:)
【问题讨论】:
标签: matlab image-processing signal-processing fft