Image Filtering Notes
Image Filtering
Image filtering involves replacing each pixel with a weighted average of its neighborhood to reduce noise.
The weights are determined by a filter kernel.
1D Case
A 1D filter is applied to a 1D signal by convolving the filter with the signal.
For example, given a filter and a signal , the output is calculated by taking the weighted average of the signal values under the filter.
When applying a filter, you lose pixels at the edges because the filter extends beyond the signal at these points.
Several strategies exist for handling boundaries:
Zero Padding: Assume values outside the image are zero.
Clamp to Edge: Replicate the edge pixels.
Wrap Around: Treat the image as repeating (useful for periodic patterns).
Crop: Simply crop the output to the valid region.
Image Filtering in 2D
In 2D, a similar concept applies where a 2D filter kernel is used to compute the weighted average of a pixel's neighborhood.
Given an image and a filter kernel , the filtered image is given by:
Where to defines the neighborhood around the pixel .
Example Filters
Box Filter
All weights are equal
This computes the average value in the neighborhood.
Gaussian Filter
Weights are based on a Gaussian distribution.
This gives more weight to closer pixels.
Approximates the solution to the diffusion equation.
Derivative Filters
Used to compute derivatives of the image.
Examples include the Sobel operator:
These filters are used in edge detection.
Properties of Linear Filters
Linearity: Filtering is a linear operation.
if , then
Shift Invariance: The result of filtering does not depend on the position in the image.
if , then
Commutativity: The order of filtering does not matter when multiple filters are applied.
Associativity: Filters can be applied in stages.
Separability: Some filters can be separated into two 1D filters, which reduces computational complexity.
For example, a Gaussian filter is separable:
This means filtering can be done by first filtering all rows with and then filtering all columns with
Applications of Image Filtering
Noise Reduction: Averaging filters (like the box filter) reduce noise but also blur the image.