问题 仅来自相位/幅度的Matlab逆FFT


所以我有这个'我'的形象。我用F = fft2(I)得到2D傅里叶变换。为了重建它,我可以去ifft2(F)。

问题是,我需要仅从a)幅度和b)F的相位分量重建这个图像。我如何分离傅立叶变换的这两个分量,然后从每个变换重建图像?

我尝试了abs()和angle()函数来获得幅度和相位,但第一阶段将无法正确重建。

帮帮我?


4071
2017-10-14 04:40


起源



答案:


你需要一个矩阵大小相同的矩阵 F 和0相,和另一个相同的相 F 并且均匀的幅度。正如你所说 abs 给你量级。要获得均匀幅度相同的相位矩阵,您需要使用 angle 得到阶段,然后将阶段分成实部和虚部。

> F_Mag = abs(F); %# has same magnitude as F, 0 phase
> F_Phase = cos(angle(F)) + j*(sin(angle(F)); %# has magnitude 1, same phase as F
> I_Mag = ifft2(F_Mag);
> I_Phase = ifft2(F_Phase);

11
2017-10-14 05:32



我没有看到你引用的这个ffti()函数,你的意思是ifft2()吗?如果没有,您是否有链接到它的文档?另外,我没有看到这个arg()函数。 - Jordan
对不起,我使用的是Octave语法 arg (相当于Matlab的 angle)和my-up-my-head语法 ifft2。 - mtrw
+1, F_Phase = exp(j*angle(F)); 太! - Chris A.
'j'来自哪里? - schwiz
@schwiz: j = i = sqrt(-1)。这个(apocryphally)的历史就是这样 j 由工程师用于想象单元 i 已经用于当前。人们可能想知道原因 c 不用于当前。显然, i 表示强度,因为早期的电流是在流体流动的背景下进行分析的。到了解时,复数将有助于分析电力 i 目前是根深蒂固的。 - mtrw


答案:


你需要一个矩阵大小相同的矩阵 F 和0相,和另一个相同的相 F 并且均匀的幅度。正如你所说 abs 给你量级。要获得均匀幅度相同的相位矩阵,您需要使用 angle 得到阶段,然后将阶段分成实部和虚部。

> F_Mag = abs(F); %# has same magnitude as F, 0 phase
> F_Phase = cos(angle(F)) + j*(sin(angle(F)); %# has magnitude 1, same phase as F
> I_Mag = ifft2(F_Mag);
> I_Phase = ifft2(F_Phase);

11
2017-10-14 05:32



我没有看到你引用的这个ffti()函数,你的意思是ifft2()吗?如果没有,您是否有链接到它的文档?另外,我没有看到这个arg()函数。 - Jordan
对不起,我使用的是Octave语法 arg (相当于Matlab的 angle)和my-up-my-head语法 ifft2。 - mtrw
+1, F_Phase = exp(j*angle(F)); 太! - Chris A.
'j'来自哪里? - schwiz
@schwiz: j = i = sqrt(-1)。这个(apocryphally)的历史就是这样 j 由工程师用于想象单元 i 已经用于当前。人们可能想知道原因 c 不用于当前。显然, i 表示强度,因为早期的电流是在流体流动的背景下进行分析的。到了解时,复数将有助于分析电力 i 目前是根深蒂固的。 - mtrw


对这篇文章提出另一个答案为时已晚,但是......无论如何

@ zhilevan,您可以使用我用mtrw的答案编写的代码:

image = rgb2gray(imread('pillsetc.png')); 
subplot(131),imshow(image),title('original image');
set(gcf, 'Position', get(0, 'ScreenSize')); % maximize the figure window
%:::::::::::::::::::::
F = fft2(double(image));
F_Mag = abs(F); % has the same magnitude as image, 0 phase 
F_Phase = exp(1i*angle(F)); % has magnitude 1, same phase as image
% OR: F_Phase = cos(angle(F)) + 1i*(sin(angle(F)));
%:::::::::::::::::::::
% reconstruction
I_Mag = log(abs(ifft2(F_Mag*exp(i*0)))+1);
I_Phase = ifft2(F_Phase);
%:::::::::::::::::::::
% Calculate limits for plotting
% To display the images properly using imshow, the color range
% of the plot must the minimum and maximum values in the data.
I_Mag_min = min(min(abs(I_Mag)));
I_Mag_max = max(max(abs(I_Mag)));

I_Phase_min = min(min(abs(I_Phase)));
I_Phase_max = max(max(abs(I_Phase)));
%:::::::::::::::::::::
% Display reconstructed images
% because the magnitude and phase were switched, the image will be complex.
% This means that the magnitude of the image must be taken in order to
% produce a viewable 2-D image.
subplot(132),imshow(abs(I_Mag),[I_Mag_min I_Mag_max]), colormap gray 
title('reconstructed image only by Magnitude');
subplot(133),imshow(abs(I_Phase),[I_Phase_min I_Phase_max]), colormap gray 
title('reconstructed image only by Phase');

1
2017-11-09 08:16