Smoothing & Blurring Filters

Smoothing (blurring) reduces noise and detail in an image by averaging or modifying pixel values based on their neighbors. It works as a low-pass filter, allowing low-frequency components (smooth regions) to pass while suppressing high-frequency components (noise, edges, fine details). They are almost always the first preprocessing step before edge detection or segmentation.

Classification of Smoothing Filters

graph TD
    A[Smoothing Filters] --> B[Linear Filters]
    A --> C[Non-Linear Filters]
    
    B --> B1[Mean / Average Filter]
    B --> B2[Gaussian Filter]
    
    C --> C1[Median Filter]
    C --> C2[Bilateral Filter]
    C --> C3[Min/Max Filter]
    
    style A fill:#4A90D9,color:#fff
    style B fill:#7BB661,color:#fff
    style C fill:#E8A04C,color:#fff

1. Mean (Average) Filter

Linear Spatial
Replaces each pixel with the simple arithmetic average of all pixels in a rectangular neighborhood (kernel). Every neighbor contributes equally.

K=19111111111
When to use ?
When to avoid?
Caution

The Mean Filter is the bluntest tool in the kit. It treats noise and edge information identically. Use it only when you need fast, rough smoothing and do not care about edge sharpness.

2. Gaussian Filter

Linear Spatial
The effect of Gaussian smoothing is to blur an image, in a similar fashion to the mean filter. The degree of smoothing is determined by the standard deviation of the Gaussian.

The Gaussian outputs a weighted average of each pixel's neighborhood, with the average weighted more towards the value of the central pixels. This is in contrast to the mean filter's uniformly weighted average. Because of this, a Gaussian provides gentler smoothing and preserves edges better than a similarly sized mean filter.

How it works?

Applies a weighted average using a Gaussian (bell-curve) function. Pixels closer to the center receive a higher weight than those at the edges of the kernel. The standard deviation σ controls how much blurring is applied — a larger σ produces a stronger blur.

A common example of 3×3 discrete approximation (σ1):

K=116121242121
The 2D Gaussian Formula
G(x,y)=12πσ2ex2+y22σ2

where

Step-by-Step Example
1. Create the Kernel Weights

Let’s calculate the weights for a (3×3) kernel using a standard deviation of (σ=1). The center pixel is at (0,0).

2. Normalize the Weights

If we add up all the unrounded weights calculated above (1 center + 4 edges + 4 corners), the sum is roughly (0.667). To ensure the final image brightness remains unchanged, we divide each value by the sum of all weights. Dividing and rounding gives us a clean, integer-based (3×3) Gaussian kernel:

116121242121
3. Apply the Filter (Convolution)

Imagine a section of your image has the following pixel values:

[102010205020102010]

To find the new smoothed value for the center pixel, we multiply the image pixels by the Gaussian kernel weights and sum them up:
New Center=(10×1)+(20×2)+(10×1)+(20×2)+(50×4)+(20×2)+(10×1)+(20×2)+(10×1)16=25

4. Result

The center pixel value is smoothed from (50) down to (25), blending it into the background.

When to use ?
How to pick σ ?
When to avoid ?
Caution

Gaussian blur is the default go-to, but choosing σ too large will destroy fine details that your downstream step (e.g., edge detection) depends on. Always verify blur intensity visually or empirically.

3. Median Filter

Non-Linear Spatial
The median filter is normally used to reduce noise in an image, like the mean filter, but it does better job in preserving details in the image in comparison.

How it works?

Median filter, sorts all pixel values in the neighborhood and replaces the center pixel with the median (middle) value.
By calculating the median value of a neighborhood, the median filter has two main advantages over the mean filter:

  1. Robust to outliers: The median is a more robust average than the mean and so a single/few outlier pixel(s) in a neighborhood will not affect the median value significantly.
  2. Preserving sharp edges: Since the median filter's pick value must actually be the value of one of the pixels in the neighborhood, the median filter does not introduce new intensity pixel (calculated value) when the filter straddles an edge, thus the median filter is much better at preserving sharp edges better.
When to use?
When to avoid
Caution

The Median Filter is non-linear — it cannot be described as a simple convolution. This means it does not combine cleanly with frequency-domain analysis. It also tends to erode thin lines or small features if the kernel is too large. Use kernel size 3×3 as a starting point.

4. Bilateral Filter

Non-Linear Spatial
Bilateral filtering is an edge-preserving smoothing technique used in image processing, meaning — reduce noise while maintaining sharp boundaries in an image.

How it works?

Bilateral Filter are based on two factors:

Bilateral Filter combines both, pixels that are spatially close AND have a similar intensity to the center pixel are blended together pixels across an edge and large intensity difference are largely ignored. This ensures that only similar pixels are blended, while edges are preserved.

Formula
Ifiltered(x)=1WxiΩI(xi)fr(I(xi)I(x))gs(xix)

The Core Components

Key Features
mindmap
  root((Bilateral
Filter)) Edge Preservation Edge-Aware Smoothing Dual Gaussian Filters Spatial Gaussian Intensity Guassian Parameter Sensitivity Spatial
\sigma_s Intensity
\sigma_r Noise Reduction Computational
Complexity Gaussian
Spatial + Gaussian
Intensity
When to use
Parameters to tune
When to avoid
Disadvantages
Caution

Bilateral filtering can create a "cartoon" or "plastic" appearance if over-applied, known as the HDR effect. It can also fail to separate noise from real edges when noise amplitude is large relative to the actual edge contrast.

5. Min & Max Filters

Non-Linear Spatial