Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make unwrap_phase fail for 2D input containing NaNs #7176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 29, 2023

  1. Make unwrap_phase fail for NaN input

    It seems that the infinite loop happens inside the function `partition`
    which never exits due to `pivot` being NaN. So check `pivot` before
    passing it to that function and return error codes up the call stack
    until we can raise a proper Python exception.
    
    Not sure if that is the best way to address the problem. I understand
    little of what's going on, but it's better than hanging with one core
    stuck at 100%. Performance wise I didn't see any significant impact for
    the following snippet taken from plot_phase_unwrap.py:
    
    ```python
    import numpy as np
    from skimage import data, img_as_float, color, exposure
    from skimage.restoration import unwrap_phase
    image = color.rgb2gray(img_as_float(data.chelsea()))
    image = exposure.rescale_intensity(image, out_range=(0, 4 * np.pi))
    image_wrapped = np.angle(np.exp(1j * image))
    
    %timeit unwrap_phase(image_wrapped)
    ```
    lagru committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    2079e2e View commit details
    Browse the repository at this point in the history