Very fast 2D local maxima

Detects local maxima (peaks) in a 2D image above a specified intensity threshold, neighborhood, and optionally filters peaks by prominence
13 Descargas
Actualizado 9 jul 2025

Ver licencia

A very fast local maxima (peak detector) for 2D images using morphological maximum filtering. Ideal for video analysis when used in a loop.
User can define intensity threshold, local neighborhood and optionally filters peaks by prominence.
USAGE:
Example 1 (defult): locs = Fast_peaks2D(Img, thresh, kernel_size)
Example 2 (with prominence): locs = Fast_peaks2D(Img, thresh, kernel_size, min_prom)
Example 3 (for multiple frames):
locs = [];
for i = 1:numel(img(1,1,:))
li = Fast_peaks2D(img(:,:,i), LAFM_thresh, 1);
li = [li, i*ones(numel(li(:,1)),1)];
locs = [locs; li];
end
INPUTS:
Img - 2D image (grayscale, numeric matrix) for peak detection.
thresh - Intensity threshold; only peaks above this value are considered.
kernel_size - Size of the local neighborhood used for maximum filtering (in pixels).
min_prom - (Optional) Minimum required prominence of peaks. Peaks with lower prominence are discarded.
OUTPUT:
locs - Nx4 array where each row represents a detected peak:
[x_position, y_position, peak_height, prominence]
If min_prom is not provided, prominence is set to zero.
ISSUE: Over picks peaks on featureless or uniform regions
NOTES:
  • The function uses morphological maximum filtering and optional prominence filtering.
  • Edge pixels (within 2 pixels of the image boundary) are excluded from detection.
  • Prominence is computed as the vertical distance to the lowest point along the path to the nearest higher neighboring peak. Prominence calculations slow the code down.

Citar como

George Heath (2025). Very fast 2D local maxima (https://la.mathworks.com/matlabcentral/fileexchange/181437-very-fast-2d-local-maxima), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2025a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Agradecimientos

Inspirado por: NanoLocz - AFM Image Analysis Platform

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.1

Improved description

1.0.0