What is the difference between unwrap() function and principal value in finding the unwrapped phase?
조회 수: 29 (최근 30일)
이전 댓글 표시
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:
- by using unwrap() Matlab function.
- 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.
댓글 수: 0
채택된 답변
David Goodmanson
2021년 7월 11일
편집: David Goodmanson
2021년 7월 11일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!