2

I have two images I and J, I take X=fft(I) and Y=fft(J) to have the Fourier transforms, then I take the phase and magnitude of 'X' and 'Y' respectively.

The problem is I need to combine the phase of X and magnitude of Y to form a new image, and use ifft to reconstruct this new image, How to do that in MATLAB ?

Cape Code
  • 3,584
  • 3
  • 24
  • 45
James Yanglu
  • 39
  • 1
  • 3
  • What do you mean by "combine"? – Oliver Charlesworth Oct 09 '14 at 18:28
  • I can only advice to invest significant time in the DFT. Anyway, you can combine like this: `abs(F_x).*exp(i*angle(F_Y));` where `F_x` is the FFT of X – Maurits Oct 09 '14 at 18:39
  • Take a look at this topic [link](http://stackoverflow.com/questions/6393257/getting-fourier-transform-from-phase-and-magnitude-matlab), I think they ask the same as you. They do only the recover with one image but you can use the real and imaginary parts from different images – enric.cornella Oct 09 '14 at 18:44

1 Answers1

7

The magnitude and phase of the 2D Fourier spectrum can be expressed as the phase and absolute value of a complex number. For images in Matlab, it consist of a 2D complex array. You can create a 2D complex array merging the magnitude and phase like this:

FreqDomain = abs(Y).*exp(i*angle(X));

and feed it back into ifft2.

Note: use fft2 to calculate 2D FFTs of images.

Edit: in fact there is a full example of exactly what you are asking on this page: http://matlabgeeks.com/tips-tutorials/how-to-do-a-2-d-fourier-transform-in-matlab/

Cape Code
  • 3,584
  • 3
  • 24
  • 45