Matlab inverse FFT only on phase / magnitude

So, I have this image of "I". I take F = fft2 (I) to get the two-dimensional Fourier transform. To restore it, I could go ifft2 (F).

The problem is that I need to restore this image only from a) the magnitude and b) of the phase components F. How can I separate these two components of the Fourier transform and then restore the image from each?

I tried the abs () and angle () functions to get the amplitude and phase, but the first phase will not recover properly.

reference

+8
matlab fft phase
source share
2 answers

You need one matrix with the same size as the F and 0 phases, and another with the same phase as F and uniform. As you noted, abs gives you a value. To get the same phase matrix of the same magnitude, you need to use angle to get the phase, and then separate the phase back to the real and imaginary parts.

 > 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); 
+10
source share

it's too late to add another answer to this post, but ... anyway

@zhilevan, you can use the codes I wrote using mtrw answer:

 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'); 
0
source share

All Articles