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 = 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);

this is return me white page.

  • $\begingroup$ I suggest posting 1.bmp so that others can try it. $\endgroup$
    – Jim Clay
    May 15, 2013 at 14:39
  • $\begingroup$ You can't do that. ysbl.york.ac.uk/~cowtan/fourier/magic.html $\endgroup$
    – endolith
    May 15, 2013 at 15:19
  • 2
    $\begingroup$ 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. $\endgroup$ May 15, 2013 at 19:54
  • $\begingroup$ imagesc is another good one $\endgroup$ May 16, 2013 at 5:43

3 Answers 3


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.

enter image description here


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

  • $\begingroup$ 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/… $\endgroup$
    – Yuseferi
    May 15, 2013 at 13:42
  • 2
    $\begingroup$ 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? $\endgroup$
    – Jim Clay
    May 15, 2013 at 13:48
  • $\begingroup$ 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. $\endgroup$
    – Yuseferi
    May 15, 2013 at 14:07
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jim Clay
    May 15, 2013 at 14:33
  • $\begingroup$ 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? $\endgroup$
    – Yuseferi
    May 15, 2013 at 14:36

Try using im2double instead of


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);


And a better explanation can be found here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.