mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-28 11:25:42 +08:00
The naive 1D unwrapper does not support masked arrays because the 1D unwrapping problem has an infite number of solutions when faced with missing data. Wrap around is not implemented because 1D phase unwrapping must start at a certain pixel, and there will always be a risk of a discontinuity there, wrap around or not.
23 lines
618 B
Cython
23 lines
618 B
Cython
#cython: cdivision=True
|
|
#cython: boundscheck=False
|
|
#cython: nonecheck=False
|
|
#cython: wraparound=False
|
|
|
|
from libc.math cimport M_PI
|
|
|
|
|
|
def unwrap_1d(float[::1] image, float[::1] unwrapped_image):
|
|
'''Phase unwrapping using the naive approach.'''
|
|
cdef:
|
|
Py_ssize_t i
|
|
float difference
|
|
long periods = 0
|
|
unwrapped_image[0] = image[0]
|
|
for i in range(1, image.shape[0]):
|
|
difference = image[i] - image[i - 1]
|
|
if difference > M_PI:
|
|
periods -= 1
|
|
elif difference < -M_PI:
|
|
periods += 1
|
|
unwrapped_image[i] = image[i] + 2 * M_PI * periods
|