Spatial Filters
摘要
This chapter introduces the fundamental concepts and mathematical foundations of spatial filtering in digital image processing. It explains that unlike point-based operations, spatial filters compute each pixel’s new value using information from its surrounding neighborhood, enabling advanced operations such as image smoothing, edge detection, and noise reduction while preserving spatial structure. The chapter distinguishes between linear and nonlinear filters. Linear filters, based on convolution, use weighted combinations of neighboring pixels defined by a filter matrix or kernel. Examples include the Box filter for uniform smoothing, the Gaussian filter for isotropic blurring, and difference filters like the Laplacian for edge enhancement. The text details the mathematical principles of convolution and correlation, highlighting essential properties such as linearity, commutativity, associativity, and separability, and illustrates efficient implementations in Python using OpenCV. The chapter then transitions to nonlinear filters, which overcome the limitations of linear methods in preserving edges and fine details. Among these, the minimum, maximum, and median filters are described as effective tools for removing impulsive noise (e.g., salt-and-pepper) while maintaining structural integrity. The median filter with multiplicity window is presented as a refinement that assigns weighted importance to pixels. Through mathematical formulations, visual examples, and code demonstrations, the chapter provides a complete framework for understanding, designing, and applying both linear and nonlinear spatial filters in image enhancement and restoration.