[SciPy-User] 2D phase unwrapping

Gregor Thalhammer gregor.thalhammer@gmail....
Tue May 15 02:17:19 CDT 2012


Am 14.5.2012 um 23:47 schrieb Christoph Gohlke:

> 
> 
> On 5/14/2012 8:11 AM, Gregor Thalhammer wrote:
>> 
>> Am 12.5.2012 um 11:58 schrieb Ralf Gommers:
>> 
>>> 
>>> 
>>> On Fri, May 11, 2012 at 9:29 PM, Gregor Thalhammer
>>> <gregor.thalhammer@gmail.com <mailto:gregor.thalhammer@gmail.com>> wrote:
>>> 
>>>    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.
>>> 
>>> 
>>> Great!
>>> 
>>>    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?
>>> 
>>> 
>>> The emails about the license seem to be very clear to me, there's no
>>> issue. So all it would take is someone submitting a complete wrapper
>>> (with the normal requirements on docs/tests). The only things to
>>> decide are then: do we want it in scipy (+1 from me), where to put it
>>> and what the API should look like.
>> 
>> Over the weekend I worked on the 2D and 3D phase unwrappers. I put a
>> first version on github:
>> https://github.com/geggo/phase-unwrap
>> git://github.com/geggo/phase-unwrap.git
>> I tested it on OS X with gcc-4.2, Python 2.7 and recent cython. (it
>> crashes on Windows (MSVC 9), probably related to cython, but thats
>> another story).
>> 
>> Seems to work ok, only one basic test, no docs yet.
>> 
>> The interface is quite simple:
>> 
>> defunwrap(wrapped_array,
>> 
>> wrap_around_axis_0 = False,
>> wrap_around_axis_1 = False,
>> wrap_around_axis_2 = False):
>> 
>> it accepts an 2d or 3d numpy array or an masked array, and returns an
>> masked array if one was given. A fresh float32 array is returned. The
>> additional arguments can be used to specify cyclic boundary conditions
>> along the given axis. The calculations are internally performed with
>> float32. It should be quite straightforward to extend this to other
>> types, but I think for the most common use cases for this algorithm
>> (unwrapping of noisy data) a float32 array is sufficient.
>> 
>> I guess a proper place in scipy would be to add this extension to
>> scipy.ndimage.
>> 
>> Please, any comments are welcome. And also some hints, why it crashes on
>> Windows - or how to debug.
>> 
>> Gregor
>> 
> 
> Explicitly defining the C function return types (e.g. as void) fixes the crash for me.

> 
> Christoph


Great! Thanks a lot for spotting this. I would have never found this by myself.

Gregor




More information about the SciPy-User mailing list