bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / feature / peak / peak_local_max
function
skimage.feature.peak:peak_local_max
source: /dev/scikit-image/src/skimage/feature/peak.py :11
Signature
def peak_local_max ( image , min_distance = 1 , threshold_abs = None , threshold_rel = None , exclude_border = True , num_peaks = None , footprint = None , labels = None , num_peaks_per_label = None , p_norm = inf ) Summary
Find peaks in an image as coordinate list.
Extended Summary
Peaks are the local maxima in a region of floor(2 * min_distance + 1) (i.e. peaks are separated by at least min_distance).
If both threshold_abs and threshold_rel are provided, the maximum of the two is chosen as the minimum intensity threshold of peaks.
Parameters
image: ndarrayInput image.
min_distance: float, optionalThe minimal allowed distance separating peaks. To find the maximum number of peaks, use
min_distance=1.threshold_abs: float or None, optionalMinimum intensity of peaks. By default, the absolute threshold is the minimum intensity of the image.
threshold_rel: float or None, optionalMinimum intensity of peaks, calculated as
max(image) * threshold_rel.exclude_border: int, tuple of ints, or bool, optionalControl peak detection close to the border of
image.TrueExclude peaks that are within
floor(min_distance)of the border.Falseor0Distance to border has no effect, all peaks are identified.
positive integer
Exclude peaks, that are within this given distance of the border.
tuple of positive integers
Same as for a single integer but with different distances for each respective dimension.
The value of
p_normhas no impact on this border distance.num_peaks: int, optionalMaximum number of peaks. When the number of peaks exceeds
num_peaks, returnnum_peakspeaks based on highest peak intensity.footprint: ndarray of bools, optionalBinary mask that determines the neighborhood (where
True) in which a peak must be a local maximum (see Notes). If not given, defaults to an array of ones of sizefloor(2 * min_distance + 1).labels: ndarray of ints, optionalIf provided, each unique region
labels == valuerepresents a unique region to search for peaks. Zero is reserved for background.num_peaks_per_label: int, optionalMaximum number of peaks for each label.
p_norm: float, optionalWhich Minkowski p-norm to use. Should be in the range [1, inf]. A finite large p may cause a ValueError if overflow can occur.
infcorresponds to the Chebyshev distance and 2 to the Euclidean distance. See also numpy.linalg.norm.
Returns
output: ndarrayThe coordinates of the peaks.
Notes
The peak local maximum function returns the coordinates of local peaks (maxima) in an image. Internally, a maximum filter is used for finding local maxima. This operation dilates the original image. After comparison of the dilated and original images, this function returns the coordinates of the peaks where the dilated image equals the original image.
Examples
img1 = np.zeros((7, 7)) img1[3, 4] = 1 img1[3, 2] = 1.5 img1✓
peak_local_max(img1, min_distance=1)
✓peak_local_max(img1, min_distance=2)
✓img2 = np.zeros((20, 20, 20)) img2[10, 10, 10] = 1 img2[15, 15, 15] = 1 peak_idx = peak_local_max(img2, exclude_border=0) peak_idx✓
peak_mask = np.zeros_like(img2, dtype=bool) peak_mask[tuple(peak_idx.T)] = True np.argwhere(peak_mask)✓
See also
Aliases
-
skimage.feature.peak_local_max