Q13Digital Image Processing
Question
Explain spatial domain filtering. How does a median filter work to remove salt-and-pepper noise?
Answer
A critical mathematical breakdown of Spatial Domain Filtering. Contrasts linear convolution filters against the elite, non-linear Median Filter, explaining exactly how it violently destroys Salt-and-Pepper noise without blurring physical edges.
Spatial domain filtering is a mathematical architecture that operates directly on the raw pixel matrix , completely bypassing the complex Fourier frequency domain. A highly localized mathematical mask (a or kernel) is physically slid across every single pixel in the image to calculate a new center value.
A Linear Filter (like the Mean/Average Filter) simply calculates the mathematical average of the 9 pixels under a mask. While this blurs out Gaussian noise, it causes catastrophic damage to the image: it violently blurs sharp physical edges, making the image look out of focus.
The Median Filter completely abandons linear algebra in favor of Order-Statistics.
- Salt-and-Pepper Noise: This is impulse noise caused by a catastrophic hardware sensor failure. Random pixels violently spike to absolute maximum (255, Salt) or crash to absolute minimum (0, Pepper).
- The Execution: When the mask slides over a pixel, the algorithm physically extracts all 9 pixel values. It violently sorts them in ascending numerical order (e.g., ).
- The Mathematical Selection: It completely ignores the mean. It strictly selects the absolute median value (the 5th number in a sorted list of 9). In the example above, the median is .
- The Result: The horrific Salt noise spike () is mathematically banished to the extreme right of the sorted list and is permanently ignored. The center pixel is replaced by . The noise is violently annihilated, but because no averaging occurred, the sharp physical edges of the image remain perfectly intact.