Skip to content
AI360Xpert
Beta

Gaussian Filter Image Smoothing

A Gaussian filter blends each pixel with neighbours weighted by a bell curve. Close pixels count most, so noise fades but shapes stay fair.

A Gaussian kernel piles weight on the center and tapers outward, so close neighbours shape the output most.
A Gaussian kernel piles weight on the center and tapers outward, so close neighbours shape the output most.

Why Does This Exist?

Averaging filters treat a far neighbour the same as an adjacent one, which is why box blur looks harsh. Real optical blur falls off with distance, brightest at the center and fading outward. The Gaussian kernel copies that falloff with the bell curve G(x,y)=12πσ2e−(x2+y2)/(2σ2)G(x, y) = \frac{1}{2\pi\sigma^2} e^{-(x^2+y^2)/(2\sigma^2)}, where σ\sigma (sigma) sets the width.

It is the default pre-filter in the smoothing family and the opening step of the Canny detector. When edges must survive smoothing instead, step up to the bilateral filter.

Think of It Like This

Asking neighbours for advice

You weight advice by distance: your own judgment most, next-door neighbours somewhat, strangers across town barely. Sigma is how far your trust reaches. A tiny sigma trusts only yourself, so nothing changes; a huge sigma trusts the whole town equally, and every opinion blurs into mush. Good smoothing, like good advice, listens widely but trusts locally.

How It Actually Works

Sample the bell curve over a window, typically 3×33 \times 3 or 5×55 \times 5, and normalize so the weights sum to 1. The classic 3×33 \times 3 kernel with σ≈0.85\sigma \approx 0.85 is:

116[121242121]\frac{1}{16}\begin{bmatrix} 1 & 2 & 1 \\ 2 & 4 & 2 \\ 1 & 2 & 1 \end{bmatrix}

The center carries 4/164/16 of the vote and corners only 1/161/16 each. Because the 2D bell curve factors into horizontal times vertical, filtering runs as two 1D passes: O(k)O(k) work per pixel instead of O(k2)O(k^2).

Worked example

Drop one bright impulse into darkness:

[00001000000]\begin{bmatrix} 0 & 0 & 0 \\ 0 & 100 & 0 \\ 0 & 0 & 0 \end{bmatrix}

Gaussian output at center is 100⋅4/16=25100 \cdot 4/16 = 25. A box mean would give 100/9≈11.1100/9 \approx 11.1. The Gaussian keeps more of the spike because it trusts the center, yet still spreads it, which is exactly the gentle hush you want before differentiation.

Watch Out For

Sigma too large erases small objects

Every sigma increment widens the bell and mixes in more distant pixels. The symptom is small targets shrinking below detection size after the blur. Size the window to the noise, not the objects: kill grain with the smallest sigma that works, and never out-blur your smallest target.

The Quick Version

  • Gaussian weights fall off as a bell curve controlled by sigma.
  • Close neighbours dominate, so blur looks natural unlike box blur.
  • The kernel separates into two 1D passes for fast filtering.
  • It is the standard hush before Sobel, Laplacian, and Canny.
  • Pick the smallest sigma that kills the noise.