MATLAB Answers

What is the difference between unwrap() function and principal value in finding the unwrapped phase?

1 view (last 30 days)
I am working on DFT, and trying to reconstruct the image again from the magnitude and phase. I use two different ways to perform phase unwrapping:
  1. by using unwrap() Matlab function.
  2. by using the principal value of phase according to the following:
I found that:
  • there is a difference in the unwrapped phase in each of the two methods. However, the reconstructed image was the same (the same PSNR) in both cases.
  • the time of phase unwrapping by using principal value was significantly shorter than unwrap() Matlab function.
I'd appreciate it if someone could clarify the reason behind that.

Accepted Answer

David Goodmanson
David Goodmanson on 11 Jul 2021
Edited: David Goodmanson on 11 Jul 2021
Hi Ansam,
The atan2 function does not unwrap anything. It merely produces a four-quadrant theta, with
-pi < theta <= pi.
Consider an initial theta that runs from, say, 0 to 40*pi. The following demo code shows that as a function of theta, the output of atan2 is always between -pi and pi and produces a sawtooth-like result with jumps from -pi to pi. Applying unwrap removes the jumps and produces a continuuous angle so that theta2 runs from 0 to 40*pi and theta2 = theta.
If you plug angles into any trig function there is always the 2pi ambiguity, so theta and theta +- 2*pi*n give the same result. Therefore the unwrapped and not-unwrapped angles give the same result when pluggid into any trig function.
theta = 0:.01:40*pi
y = sin(theta);
x = cos(theta);
theta1 = atan2(y,x);
theta2 = unwrap(atan2(y,x));
plot(theta,theta1,theta,theta2)

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by