[SciPy-User] 2D phase unwrapping

Friedrich Romstedt friedrichromstedt at gmail.com
Sat May 12 06:30:03 EDT 2012


Am 11.05.2012 um 21:29 schrieb Gregor Thalhammer <gregor.thalhammer at gmail.com>:

> Hi all,
> 
> I have beend searching for an implementation for phase unwrapping in 2D (and possibly also 3D). I found this old thread in the numpy mailing list
> 
> http://mail.scipy.org/pipermail/numpy-discussion/2008-November/038873.html
> 
> which mentions the C implementation from GERI: http://www.ljmu.ac.uk/GERI/90202.htm
> 
> While searching I found remarks by the authors that these algorithms have been incorporated into scipy, however I am unable to find them in current scipy or numpy. Am I missing something obvious? 
> Instead I found this wrapper: https://github.com/pointtonull/pyunwrap
> This seems to be based on a wrapper already mentioned in the above mentioned discussion, but the links mentioned there are dead. I added some setup.py, and with some small modifications I managed to compile the extension both on OS X and Windows. 
> 
> I would like to see these algorithms included in scipy, and I am willing to work on this. So now my questions: In the old numpy-discussion thread licensing issues are raised, can anybody tell more? On the GERI homepage they distribute their code under a non-commercial-use license, but the authors seem to agree on incorporating their code into scipy. 
> Except from this, what else would be required?
> 
> Thanks for any advice
> Gregor

Hi,

I worked pretty hard on an unwrapping algorithm for Fourier tranform results. By this I noticed the following points:

• Phases are angles, so they are just identical, if their angle "value" is identical modulus 2 pi. There's nothing to tell them apart. The numerical value is just an insufficient model and we fight these insufficiencies when trying to "unwrap". They are already unwrapped. We just don't see it anymore. 

• For the special case of adding complex numbers, as in Fourier theory, I noticed that there is no mathematically consistent way of determining the 2 pi component of the sum of two complex numbers w.r.t. the angular numbers of the summands. It just depends on how you work it out to be calculated. This is because adding complex numbers works on real and imaginary part. For multiplication it's just fine to add the angles, as multiplication of complex numbers works on complex modulus and phase. 

• I suggest to leave the numerical value behind, or to use it in a way consistent with what it is supposed to model. This means to see it as a distance on the line of a circle, not on a normal cartesian axis. So if the number reaches 2 pi, it's just exactly the same point on the circle. From distances between points on the circle phase differences can be calculated easily by using school math. Of course it will still be undetermined up to 2 pi. 

I think if the problem requires unwrapping still, working on the way of posing the problem and understanding its kernel better might prove more useful in the long run that trying to fight noise which makes unwrapping algorithms break down. But this is just a gut feeling. It builds on that if some angular value requires to be interpreted as if on a cartesian scale there must be something very wrong with the interpretation after all. Angles are not like that as I mentioned in the beginning. 

This is a theoretical post and I'm not about to have any effect on what goes into scipy and what does not. :-)

Friedrich


More information about the SciPy-User mailing list