Skip to content

Gaussian Filter Explained: From Convolution Basics to Kernels, Sigma and the Frequency Domain

The Gaussian filter is the most widely used smoothing filter in image processing, remote sensing and computer vision. This guide builds it from nothing: what filtering is, how convolution works, where the bell curve comes from, how to compute a kernel by hand, why the filter is separable, what it does to frequencies and noise, and how to choose σ. Every idea comes with a worked example or a live demo.

From the basics4 interactive demosWorked examplesPython code
By Bimal Ghimire · Published November 4, 2026 · 18 min read

Key facts

  • Definition: a Gaussian filter replaces each pixel with a weighted average of its neighbours, using weights G(x, y) = exp(−(x² + y²)/(2σ²))/(2πσ²).
  • σ (standard deviation, in pixels) controls the amount of blur; the kernel radius is usually 3σ to 4σ and the weights are normalized to sum to 1.
  • Separable: a 2-D Gaussian blur = 1-D blur of rows, then of columns.
  • Frequency response is also Gaussian, H(f) = exp(−2π²σ²f²): a smooth low-pass filter with no ripples or contrast reversals.
  • Cascade: blurring with σ₁ then σ₂ equals one blur with √(σ₁² + σ₂²); a Gaussian blur is the heat equation run for time t = σ²/2.
  • Noise: white-noise standard deviation falls by about 1/(2√π σ) = 0.282/σ, at the cost of detail finer than about 7.5σ pixels.

What Is Filtering an Image?

A digital image is a grid of numbers. In a greyscale image each number is a brightness, usually from 0 (black) to 255 (white); a colour image has three such grids (red, green, blue); a satellite image may have a dozen bands of reflectance. Filtering means computing a new image in which every output pixel depends on a small neighbourhood of input pixels.

The simplest useful filter is an average: replace each pixel by the mean of itself and its eight neighbours. Random noise goes up in one pixel and down in the next, so averaging cancels much of it; the underlying scene changes slowly, so averaging mostly keeps it. The Gaussian filter refines this idea with one question: should a neighbour two pixels away count as much as the pixel itself? Physically, no. Nearby pixels are more likely to belong to the same object, so their weight should be larger.

Input (5 × 5) 505249515051505348524952120505150485152495250495150 × Kernel (÷ 16) 121242121 = Output pixel 68.1 (198×1 + 206×2 + 120×4) / 16 = 1090 / 16 = 68.125 Spike 120 is pulled down to 68.
Figure 1. One output pixel of a 3 × 3 Gaussian (binomial) filter. The four corner neighbours (50, 48, 48, 52) sum to 198 and get weight 1; the four edge neighbours (53, 52, 50, 51) sum to 206 and get weight 2; the centre gets weight 4. The weights add up to 16, so the result is divided by 16.

Convolution, Step by Step

Sliding a set of weights over a signal and computing a weighted sum at each position is called convolution (strictly, correlation; for a symmetric kernel such as the Gaussian the two are identical). In 1-D, with a kernel w of radius r:

$$g[n]=\sum_{k=-r}^{r} w[k]\;f[n+k],\qquad \sum_{k=-r}^{r}w[k]=1$$
f is the input, g the output, and w the kernel (also called the filter, mask or window). When the weights sum to 1, a constant signal passes through unchanged.

Three things decide what a convolution does: the shape of the weights (flat for a box, bell for a Gaussian), their width (σ), and what happens at the ends of the signal, where the window runs out of data (reflect, replicate, wrap or zero padding). Watch it happen below.

Interactive: a Gaussian kernel sliding over a noisy signal

Notice three things in the demo. The output (blue) is much smoother than the input (grey dots). The sharp steps become ramps about 2–3σ wide. And the narrow bump near the right end is lowered and widened: a feature narrower than the kernel loses contrast. These are the benefit and the price of every smoothing filter.

The Gaussian Function and the Meaning of σ

The weights come from the Gaussian, the same bell curve as the normal distribution in statistics:

$$G_\sigma(x)=\frac{1}{\sqrt{2\pi}\,\sigma}\exp\!\left(-\frac{x^2}{2\sigma^2}\right),\qquad \int_{-\infty}^{\infty}G_\sigma(x)\,dx=1$$
The factor 1/(√(2π)σ) makes the area exactly 1, which for a filter means "preserve the average brightness".
  • σ is a distance in pixels. 68.3% of the weight lies within ±σ, 95.4% within ±2σ and 99.7% within ±3σ.
  • Full width at half maximum (FWHM), the width where the curve is half its peak: 2√(2 ln 2) σ ≈ 2.355σ. Optics and remote sensing often quote the blur of a sensor this way.
  • Peak height 1/(√(2π)σ): doubling σ halves the peak and doubles the width; the area stays 1.

Interactive: continuous bell vs discrete kernel

Radius r = round(3σ)

For σ ≥ 1 the sampled weights (bars) sit almost exactly on the continuous curve. Move σ below about 0.8 and they no longer do: nearly all the weight falls on the centre pixel and the bars no longer describe a bell. A Gaussian narrower than a pixel cannot be represented by sampling it at pixel centres.

If you want to explore the bell curve itself, with areas and percentiles, try the normal distribution graph generator.

Building a Gaussian Kernel by Hand

Four steps turn the formula into a kernel. Here they are for σ = 1 and radius r = 2 (a 5-tap kernel).

  1. Choose the radius. Use r ≈ 3σ (here we use 2 to keep the arithmetic short; the 3σ rule would give 3).
  2. Evaluate e−i²/(2σ²) at i = −2 … 2. With σ = 1: e−2 = 0.135335, e−0.5 = 0.606531, e0 = 1. The constant 1/(√(2π)σ) can be skipped because the next step removes it.
  3. Normalize. The sum is 1 + 2(0.606531) + 2(0.135335) = 2.483732. Divide: w = [0.054489, 0.244201, 0.402620, 0.244201, 0.054489], Σw = 1
  4. Make it 2-D by the outer product wij = wiwj. The centre weight is 0.402620² = 0.162103; the corners are 0.054489² = 0.002969.
Kernel1-D weightsσ (exact variance)Where you meet it
Binomial 3-tap[1 2 1] / 40.707The 3 × 3 kernel of Figure 1; Sobel's smoothing part
Binomial 5-tap[1 4 6 4 1] / 161.000Burt–Adelson image pyramids; OpenCV with ksize = 5 and σ ≤ 0
Sampled σ = 1, r = 2[0.0545 0.2442 0.4026 0.2442 0.0545]0.961Example above (truncation narrows it)
Sampled σ = 1, r = 3[0.0044 0.0540 0.2420 0.3991 0.2420 0.0540 0.0044]0.9983σ rule

The "exact variance" column is Σ i² wi, the true σ² of the discrete kernel. The binomial kernels are rows of Pascal's triangle divided by their sum. By the central limit theorem they converge to a Gaussian, which is why they are often used as cheap, integer-only Gaussians.

Try it: the Gaussian Filter Calculator builds the kernel for any σ and size, shows each of these steps with your numbers, and exports the result as NumPy code.

The 2-D Gaussian and Separability

Images are 2-D, so we need the 2-D Gaussian. Because ea+b = eaeb, it factors into a product of two 1-D Gaussians:

$$G_\sigma(x,y)=\frac{1}{2\pi\sigma^2}e^{-\frac{x^2+y^2}{2\sigma^2}}=\underbrace{\frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{x^2}{2\sigma^2}}}_{G_\sigma(x)}\cdot\underbrace{\frac{1}{\sqrt{2\pi}\sigma}e^{-\frac{y^2}{2\sigma^2}}}_{G_\sigma(y)}$$
It depends only on the distance √(x² + y²), so it is also rotationally symmetric: it blurs equally in every direction.

This factorization means a 2-D blur can be done in two 1-D passes: first blur every row, then blur every column of the result. For a kernel of size n, a direct 2-D convolution needs n² multiplications per pixel; the separable version needs 2n.

121 × 121 = 121242121 column (÷4) × row (÷4) = 2-D kernel (÷16) 3 × 3: 9 vs 6 operations 25 × 25: 625 vs 50
Figure 2. Separability: the 2-D kernel is the outer product of a column and a row kernel. The saving grows with the kernel size.
σ (px)Size (3σ rule)Direct 2-D ops/pixelSeparable ops/pixelSpeed-up
17 × 749143.5×
213 × 13169266.5×
531 × 319616215.5×
1061 × 613,72112230.5×

A remarkable fact: the Gaussian is essentially the only function that is both separable and rotationally symmetric. That combination is why it appears everywhere, from image blur to the Maxwell–Boltzmann velocity distribution of gas molecules.

The Gaussian Filter in the Frequency Domain

Any image can be written as a sum of sinusoidal patterns of different spatial frequencies f (cycles per pixel). Coarse shapes are low frequencies; fine texture, sharp edges and pixel noise are high frequencies. The convolution theorem says that convolving in space multiplies in frequency, so a filter is fully described by its frequency response H(f): the factor by which it multiplies each frequency.

$$\mathcal{F}\{G_\sigma\}(f)=H(f)=e^{-2\pi^2\sigma^2f^2}\qquad\text{(in 2-D: }e^{-2\pi^2\sigma^2(f_x^2+f_y^2)}\text{)}$$
The Fourier transform of a Gaussian is another Gaussian, with width 1/(2πσ) in frequency. Wide in space means narrow in frequency, and vice versa.

A sinusoid with a period of p pixels (f = 1/p) is therefore multiplied by e−2π²σ²/p². With σ = 2, a pattern with a 10-pixel period keeps 45% of its contrast; a 4-pixel pattern keeps 0.7%. The −3 dB cutoff (gain 0.707) is at fc = √(ln 2)/(2πσ) ≈ 0.1325/σ, a period of about 7.55σ pixels.

Interactive: Gaussian vs box filter of the same width

The box (mean) filter's response is a sinc-like curve with negative lobes: some fine patterns are passed with inverted contrast, so dark stripes become light. The Gaussian's response is never negative, and it falls smoothly and monotonically. That is why a Gaussian blur looks "natural", like an out-of-focus lens, while a box blur shows faint artefacts on fine textures.

Why the Gaussian? Six Properties That Make It Special

1. Blurs add in quadrature

Gσ₁ * Gσ₂ = G√(σ₁²+σ₂²). Variances add, as for independent random variables. Two blurs of σ = 3 equal one of σ = 4.24, not 6.

2. Central limit theorem

Repeating any small averaging filter converges to a Gaussian. Three box blurs in a row already approximate one Gaussian closely, a trick used by fast blur algorithms.

3. It is the heat equation

Diffusing an image by ∂u/∂t = ∇²u for time t gives exactly Gσ * f with σ = √(2t). Blur is diffusion of brightness.

4. No new structure

Gaussian smoothing never creates new local maxima or minima in 1-D; it only removes them. This "causality" makes it the unique kernel of scale-space theory (Koenderink, Lindeberg).

5. Best space–frequency trade-off

The Gaussian has the smallest possible product of width in space and width in frequency (the Gabor–Heisenberg limit): it is as compact in both domains as any function can be.

6. Sensors are roughly Gaussian

Lens blur, atmospheric scattering and detector footprints combine (property 2) into a point spread function that is often close to Gaussian, which makes it a natural model for imaging systems.

Interactive: the central limit theorem in action

How Much Noise Does a Gaussian Filter Remove?

Suppose each pixel carries independent noise with standard deviation σₙ (white noise). The filtered value is a weighted sum, and the variance of a weighted sum of independent variables is the sum of the squared weights times the variance:

$$\operatorname{Var}\Big(\sum_k w_k\,n_k\Big)=\sigma_n^2\sum_k w_k^2\;\;\Rightarrow\;\;\sigma_{\text{out}}=\sigma_n\sqrt{\textstyle\sum_{i,j}w_{ij}^2}\approx\frac{\sigma_n}{2\sqrt\pi\,\sigma}$$
The approximation replaces the sum by an integral, ∫∫Gσ² dx dy = 1/(4πσ²), and is accurate for σ ≳ 1.
σ (px)Noise keptNoise reduction−3 dB detail period
128.2%11.0 dB7.5 px
214.1%17.0 dB15.1 px
39.4%20.5 dB22.6 px
55.6%25.0 dB37.7 px

The noise falls only as 1/σ, but the finest surviving detail grows as σ. There is always an optimum σ that balances the two, and it depends on the image: an image with large, smooth regions tolerates a large σ, while one full of sharp edges and text does not. The σ search in the calculator finds this optimum by maximizing the PSNR. On its synthetic satellite scene with noise σₙ = 35, the best σ is only about 0.9 pixels, with a gain of about 6.7 dB.

Correlated noise is different. The 1/σ law assumes independent pixels. Noise that is already spatially correlated (for example after resampling, JPEG compression or sensor crosstalk) is reduced less.

Applications of the Gaussian Filter

Pre-smoothing for derivatives

Gradients and Laplacians amplify noise. Canny edge detection and the Laplacian of Gaussian start with a Gaussian blur.

Anti-aliasing before downsampling

Remove detail the coarser grid cannot represent; scikit-image uses σ = (d − 1)/2 for a downscale factor d.

Scale space and features

SIFT and blob detectors compare an image blurred with a ladder of σ values to find structures at every size.

Image pyramids and fusion

Blur, subsample, repeat: Gaussian pyramids support multi-resolution processing, image blending and Laplacian pyramids.

Remote sensing

Modelling a sensor's point spread function, simulating a coarser sensor from a finer one, smoothing DEMs before computing slope, and building high-pass detail layers for pan-sharpening.

Beyond images

Smoothing time series (a Gaussian kernel smoother), kernel density estimation of point data in GIS heat maps, and the radial basis function kernel in machine learning.

Gaussian vs Mean, Median and Edge-Preserving Filters

FilterTypeStrengthWeaknessBest for
GaussianLinearSmooth response, separable, well understoodBlurs edgesGaussian noise, pre-smoothing, scale space
Mean (box)LinearFastest (running sums)Ripples in frequency, blocky blurQuick averaging, integral images
MedianNonlinearRemoves outliers, keeps edgesRemoves thin lines and cornersSalt-and-pepper (impulse) noise
BilateralNonlinearSmooths inside regions, keeps edgesSlower, can create staircase effectsPhotos, edge-preserving smoothing
Non-local means, BM3DNonlinearState-of-the-art classical denoisingMuch slower, more parametersHigh-quality denoising
Lee, Frost, Gamma-MAPAdaptiveModel multiplicative speckleSpecific to radarSAR images

Gaussian Filter in Python, from Scratch and with SciPy

import numpy as np
from scipy import ndimage

def gaussian_kernel_1d(sigma, truncate=3.0):
    r = int(truncate * sigma + 0.5)
    x = np.arange(-r, r + 1)
    w = np.exp(-x**2 / (2 * sigma**2))
    return w / w.sum()

def gaussian_blur(img, sigma):
    """Separable Gaussian blur with reflect padding."""
    w = gaussian_kernel_1d(sigma)
    r = len(w) // 2
    out = img.astype(float)
    for axis in (0, 1):                                  # columns, then rows
        pad = [(r, r) if a == axis else (0, 0) for a in range(out.ndim)]
        p = np.pad(out, pad, mode='symmetric')           # = SciPy 'reflect'
        out = sum(w[k] * np.take(p, np.arange(k, k + out.shape[axis]), axis=axis)
                  for k in range(len(w)))
    return out

img = np.random.default_rng(0).normal(128, 20, (64, 64))
mine = gaussian_blur(img, 2.0)
ref  = ndimage.gaussian_filter(img, 2.0, truncate=3.0)  # same kernel, mode='reflect'
print(np.abs(mine - ref).max())                          # ~6e-14

For real work use the library function: ndimage.gaussian_filter (SciPy), cv2.GaussianBlur (OpenCV) or skimage.filters.gaussian. For a colour or multiband image, pass σ = 0 on the band axis so the bands are not mixed, for example sigma=(2, 2, 0).

Common Mistakes with Gaussian Filters

  • Confusing σ with the kernel size. "A 5 × 5 Gaussian" says nothing about σ. Specify σ; derive the size.
  • Forgetting to normalize after sampling and truncating, which brightens or darkens the image.
  • Using pixels when you mean metres. In geospatial data σpixels = σmetres / pixel size. The same σ = 2 px means 20 m on Sentinel-2 and 60 m on Landsat.
  • Blurring across bands or time. A 3-D call such as gaussian_filter(cube, 2) also smooths along the spectral or temporal axis.
  • Ignoring borders and no-data. Zero padding darkens edges; NaN or fill values (e.g. −9999) spread into valid pixels. Use normalized convolution: blur the data with no-data set to 0, blur a validity mask, and divide.
  • Adding blurs linearly. σ = 2 then σ = 2 is σ = 2.83, not 4.
  • Expecting it to remove salt-and-pepper or speckle noise. Use a median or a speckle filter.

Related Tools and Guides

Frequently Asked Questions

What does a Gaussian filter do to an image?

It replaces every pixel by a weighted average of its neighbourhood, with weights that follow a bell-shaped Gaussian curve: the centre pixel counts most and the weight decays smoothly with distance. The result is a blurred image with less noise and less fine detail. Edges become gradual ramps whose width grows with sigma.

What is sigma in a Gaussian filter?

Sigma (σ) is the standard deviation of the Gaussian kernel, measured in pixels. It sets the amount of smoothing: about 68% of the 1-D weight lies within ±σ of the centre, the full width at half maximum is 2.355σ, and detail with a period shorter than about 7.5σ pixels is attenuated by more than 3 dB.

What is the formula of the Gaussian kernel?

In 2-D, G(x, y) = (1/(2πσ²)) · exp(−(x² + y²)/(2σ²)). For a discrete kernel the function is evaluated at integer offsets from −r to r and divided by the sum of all values, so the weights add up to exactly 1. For σ = 1 and a 5-tap kernel the 1-D weights are 0.0545, 0.2442, 0.4026, 0.2442 and 0.0545.

How big should a Gaussian kernel be?

The radius should be about 3σ (99.7% of the weight) to 4σ; the size is then 2r + 1. A σ of 1 needs a 7 × 7 kernel by the 3σ rule; a σ of 2 needs 13 × 13. A kernel much smaller than this truncates the bell and behaves partly like a box filter.

Why is the Gaussian filter separable?

Because exp(−(x² + y²)/2σ²) = exp(−x²/2σ²) · exp(−y²/2σ²). A 2-D Gaussian blur can therefore be done as a 1-D blur along the rows followed by a 1-D blur along the columns, giving the same result with 2n instead of n² multiplications per pixel.

What is the difference between a Gaussian filter and a mean filter?

A mean (box) filter gives every pixel in the window the same weight. Its frequency response is a sinc function with negative side lobes, so it lets some fine patterns through and can even invert their contrast. The Gaussian has a Gaussian frequency response that decreases smoothly to zero, so it blurs more naturally and introduces no artefacts.

Is Gaussian blur the same as the heat equation?

Yes. Diffusing an image with the heat equation ∂u/∂t = ∇²u for a time t gives exactly a Gaussian blur with σ = √(2t). This is why repeated Gaussian blurs add in quadrature and why the Gaussian is the basis of scale-space theory.

References

Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th ed.), Chapters 3 and 4. Pearson.

Koenderink, J. J. (1984). The structure of images. Biological Cybernetics, 50(5), 363–370.

Lindeberg, T. (1994). Scale-Space Theory in Computer Vision. Springer.

Burt, P. J., & Adelson, E. H. (1983). The Laplacian pyramid as a compact image code. IEEE Transactions on Communications, 31(4), 532–540.

Getreuer, P. (2013). A survey of Gaussian convolution algorithms. Image Processing On Line, 3, 286–310. doi.org/10.5201/ipol.2013.87

Schowengerdt, R. A. (2007). Remote Sensing: Models and Methods for Image Processing (3rd ed.). Academic Press.

Bracewell, R. N. (2000). The Fourier Transform and Its Applications (3rd ed.). McGraw-Hill.

Cite this article: Ghimire, B. (2026). Gaussian Filter Explained: Kernel, Sigma, Formula & Examples. Engineers Views. https://engineersviews.com/blog/gaussian-filter-explained/