xpunwrap.algorithms.algo_ls_weighted

xpunwrap.algorithms.algo_ls_weighted(phase_wrapped: ndarray, border_thresh=1.5, n_iter=200, restore_plane: bool = False)[source]

Weighted least-squares unwrapping with border masking.

This is a simplified binary-weight Jacobi variant of the weighted LS method from Ghiglia and Romero.

Parameters:
  • phase_wrapped (xp.ndarray) – Wrapped phase, shape (H, W) or (N, H, W), values in [-pi, pi).

  • border_thresh (float) – Gradient magnitude threshold for border detection.

  • n_iter (int) – Jacobi iterations for the weighted Poisson solve.

  • restore_plane (bool, optional) – If True, add back the mean wrapped-gradient plane. Default False.

Returns:

phase_unwrapped – Unwrapped phase, same shape as input.

Return type:

xp.ndarray

Notes

The Jacobi solver uses periodic boundary conditions via circular shifts (xp.roll): the left/right and top/bottom edges of the domain are treated as connected. No zero-padding is applied. The border-weight mask (controlled by border_thresh) mitigates edge artifacts by down-weighting high-gradient boundary regions, making this algorithm more robust to non-periodic data than the pure FFT solvers. Convergence requires n_iter to be large enough relative to the image size; the default of 200 is conservative for typical holography image sizes.

References