所以我有這個形象'我'。我用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! –