StrataQuest Home StrataQuest Glossary Custom filter
Image Processing & Correction

Custom filter

Write the weights yourself — the convolution operation in your hands

View
Definition
Custom filter performs convolutionLoading... with a user-defined kernel of weights. Mathematically: O(x, y) = Σᵢ Σⱼ I(x+i, y+j) · K(i, j), where K is the user-supplied kernel and the sum runs over kernel positions (i, j). The math is identical to every other convolutional filter; the kernel is the parameter. A 3×3 kernel of all 1/9 values produces uniform averaging — equivalent to Average filterLoading.... A center-weighted kernel summing to 1 produces Gauss-style smoothing. A kernel of [−1,0,1; −2,0,2; −1,0,1] produces the horizontal SobelLoading... gradient. The Custom filter is where these named filters end up as special cases.
The kernel is the filter
Every named filter is a Custom filter with a chosen kernel
Kernel sum determines brightness behavior
Sum = 1 preserves brightness; sum = 0 produces edge response
Symmetry shapes directional behavior
Asymmetric kernels detect specific orientations
Larger kernels capture larger features
5×5 and 7×7 are the natural next sizes — but at a cost

The math, in two registers

Discrete 2D convolution with a kernel K of size (2k+1)×(2k+1) centered on the origin is:

O(x, y) = Σᵢ₌₋ₖ^k Σⱼ₌₋ₖ^k I(x+i, y+j) · K(i, j)

The notation hides a subtlety. Mathematicians often define convolution with a flipped kernel: (I * K)(x, y) = Σ I(x−i, y−j) K(i, j). Image-processing engineers usually leave the kernel unflipped (technically a correlation, not a convolution) because most kernels of interest (Gauss, Laplace) are symmetric and the distinction vanishes. The asymmetric kernels (Sobel) are designed by image-processing convention with no flip — what the engine implements as convolution is the math written above.

Linearity properties make convolutional filters composable: (K₁ + K₂) * I = K₁ * I + K₂ * I, and (K₁ * K₂) * I = K₁ * (K₂ * I). The first lets you build complex filters by adding simpler ones. The second lets you apply a single combined kernel instead of two sequential filters — useful when the combined kernel is small but the individual ones aren't.

Brightness preservation is a kernel property: if Σ K = 1, then convolving a uniform image of value c with K produces a uniform image of value c. If Σ K = 0, the output is zero on uniform regions and nonzero only where the image varies — this is the edge-detection regime.

Simplified

At every pixel position, the filter places the kernel grid on the image, multiplies each kernel cell by the input pixel underneath it, adds up the results, and writes the sum to the corresponding output position. Same gesture for every pixel; the kernel doesn't change.

A few rules of thumb worth knowing. If you add up the kernel's values and they total 1, the filter preserves the image's average brightness. If they total 0, the output is dark in flat regions and only lights up at edges — that's the edge-detection family. If they total something else, the image gets brighter or darker overall as a side effect of the math.

Share This Term
Term Connections