我怎样才能从傅里叶谱中恢复我的图像

How can I restore my image back from the Fourier Spectrum

我拍了下图: PandaNoise.bmp 并试图通过关注其傅立叶频谱来消除周期性噪声。注释行是我不确定的行。我无法将其恢复到图像平面。我在这里做错了什么?

panda = imread('PandaNoise.bmp');
fpanda = fft2(panda); % 2d fast fourier transform
fpanda = fftshift(fpanda); % center FFT
fpanda = abs(fpanda); % get magnitude
fpanda = log(1 + fpanda); % use log to expand range of dark pixels into bright region
fpanda = mat2gray(fpanda); % scale image from 0 to 1
figure; imshow(fpanda,[]); % show the picture
zpanda = fpanda;
zpanda(fpanda<0.5)=0;
zpanda(fpanda>0.5)=1;
%img = ifft2(zpanda);
%img = ifftshift(img);
%img = exp(1-img);
%img = abs(img);

下面是一个如何使用复数傅里叶变换的示例。我们可以取对数模来显示,但是不要改变原来的傅里叶变换矩阵,因为我们用abs丢掉的相位信息很重要

% Load data
panda = imread('https://i.stack.imgur.com/9SlW5.png');
panda = im2double(panda);

% Forward transform
fpanda = fft2(panda);

% Prepare FT for display -- don't change fpanda!
fd = fftshift(fpanda);
fd = log(1 + abs(fd));
figure; imshow(fd,[]); % show the picture
% From here we learn that we should keep the central 1/5th along both axes

% Low-pass filter
sz = size(fpanda);
center = floor(sz/2)+1;
half_width = ceil(sz/10)-1;
filter = zeros(sz);
filter(center(1)+(-half_width(1):half_width(1)),...
       center(2)+(-half_width(2):half_width(2))) = 1;
filter = ifftshift(filter); % The origin should be on the top-left, like that of fpanda.
fpanda = fpanda .* filter;

% Inverse transform
newpanda = ifft2(fpanda);
figure; imshow(newpanda);

计算 ifft2 后,如果我们正确设计滤波器(即围绕原点完全对称),newpanda 应该是纯实值。任何仍然存在的虚构部分都应该是纯粹的数字错误。 MATLAB 将检测到 ifft2 的输入是共轭对称的,而 return 是纯实数结果。 Octave 不会,您必须执行 newpanda=real(newpanda) 以避免来自 imshow.

的警告