1

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

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
4

1 回答 1

2

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

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

对于你想要的,你必须保持 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 的值,你可以检查一下。

于 2014-04-24T16:23:09.297 回答