2

I process image using MatLab.

I do the following steps on an image:

  1. I make an image read.
  2. I take the Fourier of image.
  3. I take the real of Fourier transformed image.

While performing above steps I got a double rotated image in result. I don't know its reason why this happened.

Can some one please explain its reason that why in result a double rotated image produced?

The piece of code is here:

imfftreal = real(imfft);
im = uint8(ifft2(imfftreal));
imshow(im);
Figure;
Failed Scientist
  • 1,977
  • 3
  • 29
  • 48
Sipa
  • 383
  • 1
  • 13
  • please attach the input image and the resulting "rotated image" so we can better understand your problem. – Shai May 15 '16 at 10:43
  • Seems to be a duplicate of: http://dsp.stackexchange.com/questions/30770/why-real-part-of-fft-converts-image-into-rotation-original – hotpaw2 May 16 '16 at 00:51

2 Answers2

0

To get the image right you need the imaginary part also. You used only the real part while taking inverse transform.

imfftReal = real(imfft);
imfftImag = imag(imfft);
re_imfft=imfftReal +1i*imfftImag;
im = uint8(ifft2(re_imfft));
imshow(im);

In case of Magnitude and Phase

imfftMagnitude = abs(imfft);
imfftPhase = angle(imfft);
re_imfft=imfftMagnitude.*exp(1i*imfftPhase);
im = uint8(ifft2(re_imfft));
imshow(im);
Rijul Sudhir
  • 2,064
  • 1
  • 15
  • 19
  • Hi thanks for answer but my question is why image double rotated what is the theory behind this i want to know that please explain... – Sipa May 15 '16 at 09:37
0

I experienced same issue exactly and posted it on DSP StackExchange mere two days ago.

@M529 given a very good and simple explanation of it:

If you have a data set which is purely real, its (inverse) Fourier transform will have Hermitian symmetry: If you find the value z at position (x,y), then you will find the complex conjugate value z∗ at the point-reflected position (−x,−y) about the origin. Note that the origin here would be the center of Fourier-space. This can be reformulated, of course, if the DC component is not in the center of your FFT implementation. And this is what you see in your image: A point-reflected version is overlaying the true image - because you forced one space to be real valued.

This property is actually being used for accelerating magnetic resonance imaging (MRI) in some cases: MRI acquires the data directly in Fourier-space. Since an ideal MR image can be described by real values only (all excited magnetization vectors have phase 0), you only have to acquire half of the data space, which saves you half of the imaging time. Of course, MR images are not completely real valued due to the limiations of reality... but with a few tricks you can still use this technique advantageously.

If you want to see Maths behind it, you can find the detailed answer by @ThP there: https://dsp.stackexchange.com/questions/30770/why-real-part-of-fft-converts-image-into-rotation-original/30774#30774

Community
  • 1
  • 1
Failed Scientist
  • 1,977
  • 3
  • 29
  • 48