StrataQuest Home › StrataQuest Glossary › Average filter
BOM Operation

Average filter

The simplest convolutional smoother: equal weights that sum to one

View
Definition
An average filter replaces each pixel with the mean of the pixels in a kernel centered on it. In StrataQuest, Kernel radius (px) sets the size (default 1; radius 3 gives 7×7) and Kernel shape its outline (default Disk). With a square N×N kernel this is O(x, y) = (1/N²) · Σᵢ Σⱼ I(x+i, y+j), a convolutionLoading... with the constant kernel K(i, j) = 1/N². Its weights sum to 1, preserving overall brightness.
Supporting
H&EDSPTCH
Video · Supporting
Uniform weights, no preference
Every pixel in the window counts equally
Window size sets the scale
Bigger N, more smoothing, more blur
Frequency view: a sinc
Its Fourier transform shows the box's limits
Outliers shift the mean
One hot pixel raises every nearby output

The math, in two registers

Written out for a square 3×3 window (the default Kernel shape is Disk) at output position (x, y), the average is:

O(x, y) = (1/9) · [I(x−1,y−1) + I(x,y−1) + I(x+1,y−1) + I(x−1,y) + I(x,y) + I(x+1,y) + I(x−1,y+1) + I(x,y+1) + I(x+1,y+1)]

Two computational notes. First, the box is separable: the 2D N×N box is the outer product of two 1D boxes of length N, so filtering rows and then columns costs O(WHN) instead of O(WHN²). Second, a running sum can slide with the window, adding the entering column and subtracting the leaving one. That brings the cost to O(WH) whatever the window size, and most production implementations use it.

Simplified

For a square 3×3 window centered on (x, y), add the 9 pixels and divide by 9. For 5×5, add 25 and divide by 25. Larger windows sum more pixels over a larger denominator.

Efficient implementations don't recompute the sum at every pixel. They slide a running total across the image, adding the new edge and subtracting the old, so the filter runs at the same speed whatever the window size.

Share This Term
Term Connections