Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Non-Maximum Suppression

Overview

Non-maximum suppression (NMS) extracts discrete peak locations from a continuous 2D response map (e.g., the output of FRST or RSD). It suppresses nearby weaker responses to produce a sparse set of well-separated candidate centers.

Algorithm

For each pixel in the response map:

  1. Check if the pixel value exceeds threshold. Skip if not.
  2. Compare against all pixels within a square window of half-size radius. The pixel must be strictly greater than every neighbor in the window to qualify as a peak.
  3. Collect all qualifying peaks and sort by descending score.
  4. Truncate to max_detections entries.

The result is a Vec<Peak>, where each Peak carries a PixelCoord (sub-pixel position at integer coordinates) and a score (the response value at that location). Peaks are returned in descending score order, providing a natural ranking for downstream stages.

Configuration

#![allow(unused)]
fn main() {
pub struct NmsConfig {
    /// Suppression radius (half-window size in pixels). Default: 5.
    pub radius: usize,
    /// Minimum response to consider. Default: 0.0.
    pub threshold: f32,
    /// Maximum number of peaks to return. Default: 1000.
    pub max_detections: usize,
}
}
FieldEffect of increasing
radiusFewer, more spread-out peaks
thresholdEliminates weak candidates early
max_detectionsHigher budget cap, more proposals to evaluate