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.
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 , where (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 or , and normalize so the weights sum to 1. The classic kernel with is:
The center carries of the vote and corners only each. Because the 2D bell curve factors into horizontal times vertical, filtering runs as two 1D passes: work per pixel instead of .
Worked example
Drop one bright impulse into darkness:
Gaussian output at center is . A box mean would give . 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.