MATLAB Answers

How to perform ifft2 with phase and magnitude

22 views (last 30 days)
Changoleon
Changoleon on 25 Sep 2016
Answered: Walter Roberson on 26 Sep 2016
Hi. I really tried to find the answer for my questions but I didn't find it online.
So I have two images which correspond to the magnitude and phase following a Fourier transform of an image. Now I want to write a function to convert the magnitude image and phase image into the original image in spatial domain. The question also states that "For the phase image, 0 corresponds to –pi and 255 corresponds to +pi. All values in between have been linearly interpolated between –pi and pi and For the magnitude image, the intensities were log-transformed prior to saving the image, where 0 corresponds to e0 and 255 corresponds to e18."
Here is what I tried:
m1 = double(imread('magnitude1.tif'));
p1 = double(imread('phaseD.tif'));
newfft = m1.* exp(1i*p1);
out = ifft2(newfft);
My problem is I don't know how to change the values from 0 to 255 to be - pi to pi.
Any ideas would be appreciated.

Answers (1)

Walter Roberson
Walter Roberson on 26 Sep 2016
((double(p1) / 255 * 2 - 1) * pi
Or you might prefer
double(p1) / 255 * 2 * pi - pi

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!