The 2D smoothing kernel with a stencil of [1 2 1] represents a simple, yet effective method for smoothing a surface. This stencil typically forms a part of a larger convolution kernel applied over an image to average height values, effectively reducing noise and detail.
This kernel is often used in conjunction with a similar vertical stencil to create a two-dimensional convolution mask. In practice, the [1 2 1] stencil is one row of a matrix, with possibly a corresponding column vector [1; 2; 1], used to perform a 2D convolution operation on a surface.
When applied, each height in the resulting surface is a weighted average of its neighbors with the weights given by the kernel:
- The central height in the neighborhood receives the highest weight, typically reflecting higher importance or influence on the resulting height value.
- The adjacent heights horizontally (and vertically, when combined with the vertical vector) receive a lower weight than the central height but contribute significantly to the smoothing effect.
- Corner heights, if included by expanding the kernel to a full 2x2 or 3x3 matrix using both horizontal and vertical components, would receive the lowest weights.
In terms of application, the resulting convolution matrix for the two-dimensional case is :
$$
\begin{matrix}
1 & 2 & 1 \\
2 & 4 & 2 \\
1 & 2 & 1
\end{matrix}
$$
This configuration spreads the influence of a single height to its eight neighbors in a weighted manner, with a stronger influence horizontally and vertically, rather than diagonally.
The strength of smoothing is adjusted by normalizing this kernel (dividing all entries by the sum of the entries, which is 16 in the standard case), thereby ensuring that the total influence in the area remains constant, preserving overall height.