ImageEn, unit ImageEnProc

TImageEnProc.MedianFilterFast

TImageEnProc.MedianFilterFast

Declaration

procedure MedianFilterFast(Passes: Integer = 1);

Description

Apply an exact 3x3 median filter using a fast sorting-network algorithm (Perreault). This is ideal for removing salt-and-pepper / impulse noise. If some noise remains, increase Passes to run the filter again on the result.

Supported formats: ie8g, ie16g, ie24RGB and ie48RGB.

Note: For larger windows, adaptive thresholding, or sharpen/edge-extract modes, use MedianFilter

MedianFilter vs MedianFilterFast

Use MedianFilterFast when you need a true 3x3 median to remove salt-and-pepper / impulse noise (hot pixels, speckles). It uses a Perreault sorting-network algorithm, always replaces each pixel with the exact median of its 3x3 neighbourhood, and supports grayscale and high-bit-depth formats (ie8g, ie16g, ie24RGB, ie48RGB). For denser noise, increase Passes to run the filter again on the result.
Use MedianFilter for general median filtering with windows from 3x3 to 19x19, optional adaptive thresholding to preserve edges, and sharpen / edge-extract modes (mfMedianFilter, mfSharpen, mfEdgeExtract). It is based on a fast sliding-window histogram method (Huang / Scollar) and works on true-color images (ie24RGB; other formats are converted).

Examples

// Remove impulse noise with a single pass
ImageEnView1.Proc.MedianFilterFast();

// Heavy noise: apply three passes
ImageEnView1.Proc.MedianFilterFast( 3 );