# recover image by only magnitude of image fourier transform

I have a image and I want calculate fft2 of it, after it I want recover image only by magnitude of it. how can I achieve this work?

I=imread('1.bmp');
I = rgb2gray(I);
imafft = fft2(double(I));

% Gets magnitude and phase.
mag = abs(imafft);

% Generates the modified spectrum
newfft = mag.*exp(0*angle(imafft));
ima_out = ifft2(newfft);
imshow(abs(ima_out));


this is return me white page.

• I suggest posting 1.bmp so that others can try it. May 15, 2013 at 14:39
• You can't do that. ysbl.york.ac.uk/~cowtan/fourier/magic.html May 15, 2013 at 15:19
• The reason the image is all white is because ifft2 returns doubles, and imshow assumes doubles to be normalized to [0,1], which these probably aren't. Changing the last line to imshow(abs(ima_out),[]) will set the range dynamically, but as Jim Clays's answer has already pointed out, this information is all garbage anyways. May 15, 2013 at 19:54
• imagesc is another good one May 16, 2013 at 5:43

Check out this classic example from Oppenheim, A. V., & Lim, J. S. (1981). "The importance of phase in signals". a) and b) are the original images, c) is the image created using the phase of a) with the magnitude of b), d) is the image created using the phase of b) and the magnitude of a). Phase carries most of the information in an image.

You cannot recover an image with just the frequency magnitudes. You need the phase information as well to recover it.

• I dont want recover whole image ,recover image with magnitude or phase have result but not good result . see this link.nptel.iitm.ac.in/courses/Webcourse-contents/IIT-KANPUR/… May 15, 2013 at 13:42
• Right, the link says the same thing I did, that recovering with the magnitude only doesn't work. So what are you trying to do? May 15, 2013 at 13:48
• I just want to test if I want recover my image by magnitude what image recovered, ( I know recovering by magnitude or phase solely not return perfect image ) .but I want recover only by magnitude. May 15, 2013 at 14:07
• Try recovering with just the phase and you should get something recognizable. As you have seen and as your own link shows, recovering with just the magnitude produces totally unrecognizable images. May 15, 2013 at 14:33
• I konw, I dont want regonizable image,I just want magnitude of images, I try my code but only return white page to me, where is problem? May 15, 2013 at 14:36

Try using im2double instead of

fft2(double(I));


So, will be like:

ima_double = im2double(I);

imafft = fft2(ima_double);


And when you will show the output image use:

ima_out_u8 = im2uint8(ima_out);

imshow(ima_out_u8);


And a better explanation can be found here.