Although there’s a rich set of techniques for processing images in the frequency domain, spatial domain techniques are in widespread use.
For one thing, they’re easier to implement.
Spatial processing techniques can be broadly classified as either point processing or mask processing.
Point processing modifies the value of each pixel (sometimes this is called a gray level for 8 bit images) based solely on the location of the pixel. Examples include:
- Negation - each pixel level is subtracted from the max pixel level.
- Contrast Stretching - a function is used to enhance/intensify certain regions of gray level over others.
- Thresholding – Pixels with values exceeding the threshold are transformed into the maximum value, all others are zeroed out.
Mask processing modifies the value of each pixel based on the values of all pixels in the neighborhood surrounding the pixel. The neighborhood is usually a square or rectangle of odd dimensions.
Image Averaging is a kind of mask processing whereby each pixel is replaced by a weighted average of its neighbors. This kind of processing is used to reduce some kinds of noise. The downside is that it tends to blur sharp edges; usually sharp edges represent features of interest.
Since border pixels can’t be surrounded entirely by the mask (aka window or filter) the only way to get a perfectly filtered image is to accept a slightly smaller image as output. Unfortunately this is usually unacceptable so various methods for padding are employed.
Averaging tends to suppress features that are smaller than the size of the mask.
Order Statistic Filters are non-linear filters that determine the value of a pixel based on some order statistic about its neighboring pixels. The median is an order statistic (middle-most in rank order).
The median filter tends to suppress salt-and-pepper like noise without the side effect of blurring sharp edges.