所以我有这个形象'我'。我用F = fft2(I)来获得二维傅里叶变换。重建它,我可以去ifft2(F)。从相位/大小的Matlab逆FFT仅
问题是,我需要从a)幅度和b)F相位分量重建此图像。我怎样才能分离傅里叶变换的这两个分量,然后从每个分量重建图像?
我试过abs()和angle()函数来获得幅度和相位,但是第一个阶段不能正确重构。
帮助?
所以我有这个形象'我'。我用F = fft2(I)来获得二维傅里叶变换。重建它,我可以去ifft2(F)。从相位/大小的Matlab逆FFT仅
问题是,我需要从a)幅度和b)F相位分量重建此图像。我怎样才能分离傅里叶变换的这两个分量,然后从每个分量重建图像?
我试过abs()和angle()函数来获得幅度和相位,但是第一个阶段不能正确重构。
帮助?
您需要一个与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);
为时已晚把另一个回答这个职位,但...反正
@ 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');
我不看不到你引用的这个ffti()函数,你的意思是ifft2()吗?如果不是,你有链接到它的文档? 另外,我没有看到这个arg()函数。 – Jordan
对不起,我为'arg'(相当于Matlab的'angle')使用了Octave语法,并为'ifft2'构造了我的头语法。 – mtrw
+1,'F_Phase = exp(j * angle(F));'too! –