【问题标题】:Inverse Fourier Transform function gives wrong result傅里叶逆变换函数给出错误的结果
【发布时间】:2014-06-10 00:56:07
【问题描述】:

我正在实现图像增强代码并应用傅立叶和傅立叶逆变换我正在使用下面的代码,但结果它给出了黑色图像。

F = fft2(image); F = fftshift(F); % Center FFT
F = abs(F); % Get the magnitude
F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined
F = mat2gray(F); % Use mat2gray to scale the image between 0 and 1
Y = ifft2(F);
subplot(1,1,1);
imshow(Y,[]); % Display the result

【问题讨论】:

  • 许多 fft/ifft 实现最终会以 NxM 缩放结果,让您自己将其缩放回“正常”...我不记得 Matlab 是否是其中之一那些与否......另外,由于你没有做 fft 的 ifft(你已经以几种方式处理了 fft),结果可能不会是你想要的......
  • 犯了与this question完全相同的错误。考虑那里的 cmets。

标签: matlab image-processing fft image-enhancement


【解决方案1】:

您尝试对纯实数(正数)矩阵的逆 FFT 进行成像,abs(F)。它的逆 FT 是一个复杂的,由于你失去了原始 FT 的相位,你会得到奇怪的结果(几乎是黑色的图像,最终第一个像素是白色的......)。

第二个错误,你移动 fft 进行一些计算,但你没有反转之前的 shift

为了你想要的,你必须保持FFT的相位:

F = fft2(image); F = fftshift(F); % Center FFT
Fp = angle(F); % Get the phase
F = abs(F); % Get the magnitude
F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined
F = mat2gray(F); % Use mat2gray to scale the image between 0 and 1
Y = real(ifft2(ifftshift(F.*exp(1i*Fp))));
subplot(1,1,1);
imshow(Y,[]); % Display the result

注意:您需要取逆 FFT 的实部,因为 Matlab 会自动创建一个复数数组作为 FT(正向或逆向)的输出,即使它是实数输出。如果你在我的电脑上看到max(abs(imag(Y(:)))), 6e-11 的值,你可以检查一下。

【讨论】:

  • 也许你是对的,但我是图像处理方面的新手,所以对包含这些东西知之甚少。
  • 我应用了您的代码,但不幸的是它也给出了相同的结果,没有白色像素
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-19
相关资源
最近更新 更多