Spatial Filtering

← Back to Digital Image Processing Basics

Spatial filters operate on a neighborhood of each pixel using a convolution kernel \(w\):

\[g(x, y) = (f * w)(x, y) = \sum_{s=-a}^{a} \sum_{t=-b}^{b} w(s, t)\, f(x+s, y+t)\]

Smoothing (Low-Pass) Filters

  • Box (mean) filter: replaces each pixel with the average of its neighborhood. Simple but blurs edges.

  • Gaussian filter: weights neighbors by a Gaussian function, providing smoother results with less ringing.

  • Median filter: replaces each pixel with the median of its neighborhood. Highly effective for salt-and-pepper noise while preserving edges.

  • Bilateral filter: edge-preserving smoothing that weights neighbors by both spatial distance and intensity similarity.

  • Non-local means (NLM): exploits self-similarity across the whole image; excellent for Gaussian noise in microscopy [8].

See also