Skip to main content

Robust 2D Unwrapping Algorithm by Zixin Zhao, ported to Python.

Project description

robust_2d_unwrap

The following is an implementation of the algorithm proposed in "Robust 2D phase unwrapping algorithm based on the transport of intensity equation" (DOI:10.1088/1361-6501/aaec5c) by Zixin Zhao, Hangying Zhang, Zhaoxian Xiao, Hubing Du, Yiying Zhuang, Chen Fan and Hong Zhao.

In particular, the code is directly ported from the MatLab implementation to be python compatible.

Installation with pip

pip install robust_2d_unwrap

Basic Usage

import numpy as np
from robust_2d_unwrap import unwrap
import matplotlib.pyplot as plt

# Generate a surface, with wrapped phase for every point
h,w = 640, 480
y0, x0 = (h - 1) / 2, (w - 1) / 2
y = np.arange(h)
x = np.arange(w)
Y, X = np.meshgrid(y,x, indexing='ij')
hmap = 4 * np.exp( -( ((Y - y0)**2) / (2 * 100**2) + ((X - x0)**2) / (2 * 100**2) ))
abs_phase = hmap * 2 * np.pi
wrapped_phase = (abs_phase + np.pi) % (2 * np.pi) - np.pi

# add some noise
wrapped_phase += np.random.randn(h,w) # mu=0, std=1 rad

# visualise wrapped phase
plt.imshow(wrapped_phase) # 2d headmap
plt.title('Wrapped Phase w/ Noise')
plt.show()

# wrap phase
unwrapped_phase, _ = unwrap(wrapped_phase)

# visualize result
plt.imshow(unwrapped_phase)
plt.title('Unwrapped Phase')
plt.show()

# Noise will persist, but it will not break the unwrapping
# algorithm.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robust_2d_unwrap-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robust_2d_unwrap-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file robust_2d_unwrap-0.1.0.tar.gz.

File metadata

  • Download URL: robust_2d_unwrap-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for robust_2d_unwrap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b89a60d85b8feea7a9a000994a00d82b9e92f9309c2dd5c38deac50f4c1e8142
MD5 29564ca89658f464f7b573def7bc341c
BLAKE2b-256 f4b9cd0465ea56c2af3c27318bf99d832f5177de3202b492ba7999f5332531ee

See more details on using hashes here.

File details

Details for the file robust_2d_unwrap-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robust_2d_unwrap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96842951642f69e1aa32f96d285c8605eeb36e134a677b166d5ab15bfba1a17c
MD5 13bfffe13a1d41f3caa75460fdbe8226
BLAKE2b-256 544ef276e6799fd1f5ce2e967e3139f279cdc1713fe92ffab82ee43e6e376b50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page