# Is it possible to apply inverse Fourier transform (I-FFT) to the following image?

Suppose, I have this image in my hand and nothing else. Clearly, this is a Magnitude-plot of some unknown image.

Is it possible to apply an Inverse Fast Fourier Transform (I-FFT) operation to recover the original Grayscale image from this image?

Suppose, I have this image in my hand and nothing else. Clearly, this is a Magnitude-plot of some unknown image.

Sounds like you're losing the phase information in the signal; you only have the pixel values, correct?

Is it possible to apply an Inverse Fast Fourier Transform (I-FFT) operation to recover the original Grayscale image from this image?

The important information in images tends to edges -- edges contain most detail in the image. This information is carried in the phase information -- when decomposed into sinusoidal signals, a square wave can have arbitrary location only if the waves contain phase information.

Additionally, real world images tend to look roughly the same in the frequency spectrum when only plotting magnitude. These images tend to have a large (in magnitude) low frequency components with (much) smaller high frequency components. It's reasonable to say that a significant portion of the entropy (or information) is carried in the phase information.

With a naïve inverse Fourier transform on the values obtained from the image, it is not possible (at least by experiment) to recover the original signal. However, the phase only inverse Fourier transform (where we divide by the magnitude to only preserve the phase).

The data behind the image was generated with

x = rgb2gray(astronaut())
X = fft2(x)
X_mag = np.abs(X)  # magnitude only
X_pha = X / (np.abs(X)) # phase only
y_mag = ifft2(X_mag)  # both y_mag and y_pha have max(y.imag) < 1e-15
y_pha = ifft2(X_pha)  # (some Fourier transform theory here + floating point precision)

It is possible to reconstruct an image by IFFT from the magnitude data if the original image was perfectly symmetric around the center point. If not, no, because any asymmetry is contained in all the phase information which you no longer have from just a magnitude plot.

Yes, it is possible to recover an image if you were to run the inverse discrete Fourier Transform on this amplitude spectrum. No, it will not necessarily match exactly the image that this amplitude plot was derived from.

The Fourier Transform takes a function from the time (space) domain to the complex frequency domain. It does this by breaking down the image to "plates" of two dimensional sinusoids and cosinusoids. These two trigonometric functions ($\cos, \sin$) are orthogonal and related to the complex plane via Eueler's Identity.

It is through the relationships of the coefficients of these two functions that the three outputs of the Fourier Transform are defined:

• The Power Spectrum $$P_{u,v} = R_{u,v}^2 + I_{u,v}^2$$

• The Amplitude Spectrum $$A_{u,v} = \sqrt{R_{u,v}^2 + I_{u,v}^2}$$

• The Phase Spectrum $$Q_{u,v} = \tan^{-1}\left(\frac{I_{u,v}}{R_{u,v}}\right)$$

Where the indexes $u,v$ mark a spatial frequency component and $R,I$ are the real and imaginary parts of the complex spectrum returned by the Fourier Transform.

To run the inverse Fourier Transform and reconstruct the original image, you need both $R,I$. What you see in this image is $A$. $A$ is the result of both $R,I$ and once $R,I$ have been packaged into one number, it is impossible to unpack them back to their original values without any prior knowledge.

What you can do is take $A$ and assign it to $R$, making sure that the $I$ is zero and perform the inverse Fourier Transform. This will produce some image by superimposing spatial sinusoids all starting at the same phase, but that is not necessarily the image that $A$ resulted from originally.

Finally, please note that usually, a logarithmic transformation is applied, especially to the $P,A$ to improve the way they are visualised. The logarithmic transformation limits large values but boosts small values of the spectrum to make them more visible. The image you are attaching doesn't seem to have been transformed. There are two reasons for mentioning this. A grayscale image's colour depth might be 8-bits, which means 256 shades of gray. This is incredibly coarse, compared to the dynamic range of the single or double precision floating point numbers that are usually used to represent $A,P,Q$. This means that mere zero phase inversion of an amplitude spectrum will contain a lot of distortion due to this quantisation of the Fourier coefficients. Also, if the logarithmic transformation is not taken into account, small value coefficients will appear to have higher values which will distort the output of the Inverse Fourier Transform even more.

Hope this helps.

• "What you can do is take A and assign it to R, making sure that the I is zero and perform the inverse Fourier Transform." --- Yes. I did that. But result is not coming. .......... codeproject.com/Questions/1114190/…
– user18425
Jul 28 '16 at 23:38
• Thank you for letting me know. Please try to include the link to the original question (e.g. "For more information regarding the actual code, please see link" or include the code). We can't be "talking" across two different sites. Your ToComplex doesn't apply the FT (?). Are you sure comp is initialised to zero? On ifftButton_Click are you taking the $A$ from the button?! You have to save both $R,I$ of the forward transform somewhere and use them for IFFT NOT, some spectrum. It is exactly what is described as not to do in this answer :)
– A_A
Jul 28 '16 at 23:54

There exist an infinity of "real" images sharing exactly the same magnitude spectrum: take the spectrum, multiply it with a "phase" term (with $\exp$ ands $\imath$) having a consistent hermitian anti-symmetry, do an inverse Fourier transform, and you will have a real image. The latter is likely to have no meaning for you.

How far you will get from the original image depends on its content. If it contained a lot of edges and high-frequency textures, you are unlikely to succeed without more information. This is a long-lasting topic in image/signal processing, investigated by people like Oppenheim, Lim, Hayes.

People are currently developing image reconstruction aimed at phase retrieval using additional information: the fact that the image was coded on 8-bit for instance reduces the space of plausible solutions. If the image were sparse, you can try for instance a Matlab code for GESPAR: Efficient Phase Retrieval of Sparse Signals (1D, 2D), from Y. Shechtman, A. Beck, and Y. C. Eldar, "GESPAR: Efficient Phase Retrieval of Sparse Signals", IEEE Transactions on Signal Processing, (2014). It seems that with a sufficiently redundant transform, you could have recovered the image, but the standard FFT is just critical.

A recent overview of methods can be read in Phase retrieval with application to optical imaging: a contemporary overview.