Skip to content

min_distance in feature.peak_local_max has an unexpected behavior #4048

Closed

Description

@sciunto

Description

Increasing the min_distance value in the example below does not suppress the closest detected peaks!

Way to reproduce

# Place the full code we need to recreate your issue here
# upload all necessary images to github too!

Version information

3.7.3 (default, Jun 24 2019, 04:54:02) 
[GCC 9.1.0]
Linux-4.19.59-1-MANJARO-x86_64-with-arch-Manjaro-Linux
scikit-image version: 0.16.dev0 and 0.15.0
numpy version: 1.16.1

# your output here
import skimage
from skimage import feature
import matplotlib.pyplot as plt
%matplotlib inline

skimage.__version__


distance_map = skimage.io.imread('/tmp/toto.png')
peaks = feature.peak_local_max(distance_map)
peaks_filtered = feature.peak_local_max(distance_map, min_distance=10)

fig, ax = plt.subplots(nrows=2, figsize=(20, 20))
ax[0].imshow(distance_map)
for p in peaks:
    ax[0].plot(p[1], p[0], 'r.')
    
ax[1].imshow(distance_map)
for p in peaks_filtered:
    ax[1].plot(p[1], p[0], 'r.')

Input image

toto

result.

index

close pairs of peaks are still there... while single peaks are removed :(

Activity

  1. changed the title [-]min_distance behavior in feature.peak_local_max has an unexpected behavior[/-] [+]min_distance in feature.peak_local_max has an unexpected behavior[/+] on Jul 24, 2019
  2. rfezzani commented on Mar 15, 2020

    @rfezzani
    Member

    Isn't this the expected result? The documentation says

    If there are multiple local maxima with identical pixel intensities inside the region defined with min_distance, the coordinates of all such pixels are returned.

    What you are looking for is the corner_peak I think.

  3. jni commented on Mar 16, 2020

    @jni
    Member

    @rfezzani I still think this behaviour is surprising.

  4. rfezzani commented on Mar 16, 2020

    @rfezzani
    Member

    For sure, we must then call corner_peak internally ;-)

  5. rfezzani commented on Apr 22, 2021

    @rfezzani
    Member

    I can't reproduce this bug 🎉

    import imageio
    import skimage
    from skimage import feature
    import matplotlib.pyplot as plt
    
    print(skimage.__version__)
    
    distance_map = imageio.imread('/tmp/toto.png')
    peaks = feature.peak_local_max(distance_map)
    peaks_filtered = feature.peak_local_max(distance_map, min_distance=10)
    
    fig, ax_list = plt.subplots(ncols=3, figsize=(12, 4))
    
    for d, ax in zip([1, 5, 10], ax_list):
        ax.imshow(distance_map)
        peaks = feature.peak_local_max(distance_map, min_distance=d)
        for p in peaks:
            ax.plot(p[1], p[0], 'r.')
        ax.set_axis_off()
        ax.set_title(f"min_distance={d}")
    
    fig.tight_layout()
    plt.show()

    Figure_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions