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.