File Exchange

image thumbnail

2D and 3D Phase Unwrapping using SRNCP

version 3.0.2 (7.19 KB) by Michael Mullen
2D & 3D phase unwrapping plugins for Matlab

18 Downloads

Updated 03 Jun 2020

GitHub view license on GitHub

These files provide a means to implement the above algorithm without any special packages/toolboxes and needs any Matlab compatible C++ compiler (used Visual Studio 2019 version for this).

To compile:
mex phaseUnwrap.cpp

Input must be a real, double matrix from Matlab.

Cite As

Michael Mullen (2020). 2D and 3D Phase Unwrapping using SRNCP (https://github.com/mfmullen/PhaseUnwrapping/releases/tag/v3.0.2), GitHub. Retrieved .

Comments and Ratings (12)

It seems that using

mex -compatibleArrayDims phaseUnwrapC.c

fixes the issues with the seg fault on newer versions of Matlab. Haven't dug into why much yet, as there aren't any uses of int... only mwSize. Hope it works for everyone.

cheng yang

Thank you all for the feedback. Unfortunately, I (the contributor of this package) do not have access to Matlab 2018a. I will look into potential causes as soon as possible.

Also, I have not implemented this to work on a GPU. I apologize for any inconvenience this may cause.

Omri BarLev

I desperately need 2D phase unwrapping for large matrices.
However, as previously mentioned, I encountered the same problem as Thuc Phan.

Is there a GPU code for 2D phase unwrapping ?

ChiaJan Yv

I encountered the same problem as Thuc Phan.

Thuc Phan

Hi. I use Visual Studio Community 2015 and MATLAB R2018a to run MEX file version.

>> mex phaseUnwrapC.c
Building with 'Microsoft Visual C++ 2015 (C)'.
MEX completed successfully.

>> unwrappedImage = phaseUnwrapC(wrapped);
It popup a MathWorks Crash Reporter
MATLAB has encountered an internal problem and needs to close.

So I guess it cannot work with MATLAB 2018a. Hope someone can figure it out.

Peter

Antoine

It's working on my side, and the mex indeed provides a significant speed up (25 sec vs. 140 sec on 334x334 images).
Matlab crashed the first time I ran phaseUnwrapC (segfault), but then worked... weird
>>Caught "std::exception" Exception message is:
>>FatalException
>>Caught MathWorks::System::FatalException

I have MacOS with Matlab 2015a and XCode 8.
Mex compilation didn't work out of the box (everytime I update the OS or XCode, the whole thing breaks.)

I had to download the files here:
https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#answer_194526
and change the xml files as instructed here (basically replace all "MacOSX10.10.sdk" by "MacOSX10.10.sdk")
https://www.mathworks.com/matlabcentral/answers/303369-mex-cannot-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-8-0

I was sidetracked with other projects in the middle of testing the mex file, but I'm hoping to get around to this in the next few weeks. Also, thank you for the review; I'm glad it's working well for you!

Antoine

Works very well, out-of-the-box, and doesn't require any Matlab toolbox (always annoying.)
Thanks for providing this!
It is reasonably fast already, but I would be interested in trying the MEX version that is mentioned in the description. Where can this one be found?

Updates

3.0.2

See release notes for this release on GitHub: https://github.com/mfmullen/PhaseUnwrapping/releases/tag/v3.0.2

3.0.1

Organized/commented more thoroughly. No dramatic difference in performance.

3.0.0.2

Made compatible for 2D or 3D input phase images. Be patient with 3D.

3.0.0.1

Made C version more stable.

3.0.0.0

Found workaround to bug in previous version and updated with a C++ version to utilize som stl features.

2.5.0.0

Working excellently now, unwraps a 512x512 matrix in about 4 seconds with my system specs (compared to 45 seconds for version 2.4).

2.4.0.0

Found the bug a bit faster than anticipated. Anyway, tested to work with a 512x512 matrix now! A little slow at that size, but working to speed things up. At least it seems stable now.

2.3.0.0

Fixed bug in sorting algorithm, narrowing in on problems with large arrays.

2.2.0.0

Fixed a couple bugs in 2.1. Issue with large arrays persists.

2.1.0.0

Obtained another modest speedup. Seg fault happens for large arrays (somewhere between 300x300 and 400x400), working to fix this.

2.0.0.0

Version 2.0 includes the first version's Matlab only implementation, as well as a MEX file implementation which is about 4-5x faster.

1.3.0.0

File did not update with v1.02

1.2.0.0

Obtained a modest speed-up by eliminating some for-loops and using local functions.

1.1.0.0

Updated the description, not the files

MATLAB Release Compatibility
Created with R2019a
Compatible with any release
Platform Compatibility
Windows macOS Linux