Default `footprint` interferes with `min_distance` in `peak_local_max`

Author: lagruCreated Mar 13, 2026Updated Sep 16, 2026
Labels:sleeping: Dormant:bug: Bug

Consider an image with 2 peaks that are exactly 2 pixels apart:

python
import numpy as np
import skimage as ski

image = np.array([1, 0, 2])
ski.feature.peak_local_max(image, min_distance=2, exclude_border=0)
# array([[2]])

This removes the left peak. But I expect this to preserve both peaks, since min_distance is defined to only remove peaks that are less than min_distance from another peak with a larger intensity.

When I investigated this, I started to suspect the default footprint (generated with footprint=None) is too wide. And indeed, explicitly passing a smaller footprint leads to the behavior I expect:

python
footprint = np.ones((3,), dtype=bool)
ski.feature.peak_local_max(image, min_distance=2, footprint=footprint, exclude_border=0)
# array([[2],
#        [0]])

The default footprint is generated with https://github.com/scikit-image/scikit-image/blob/452d6b75922bab6664b9b433601e4a707d683455/src/skimage2/feature/_peaks.py#L234-L237

which for min_distance=2 leads to a footprint shape of (5,). This is used as a maximum filter and removes more peaks than min_distance itself would.

I consider this very surprising behavior, enough so, that I'd call this a bug! I think the default footprint should never remove peaks that min_distance would leave alone. Do you agree?

Source: scikit-image/scikit-image