Averaging is a special case of discrete convolution. For a 3 by 3 neighborhood, the convolution mask M is:
M = 1 9 [ 1 1 1 1 1 1 1 1 1 ] {\displaystyle M={\frac {1}{9}}{\begin{bmatrix}1&1&1\\1&1&1\\1&1&1\\\end{bmatrix}}}
The significance of the central pixel may be increased, as it approximates the properties of noise with a Gaussian probability distribution:
M = 1 10 [ 1 1 1 1 2 1 1 1 1 ] {\displaystyle M={\frac {1}{10}}{\begin{bmatrix}1&1&1\\1&2&1\\1&1&1\\\end{bmatrix}}}
M = 1 16 [ 1 2 1 2 4 2 1 2 1 ] {\displaystyle M={\frac {1}{16}}{\begin{bmatrix}1&2&1\\2&4&2\\1&2&1\\\end{bmatrix}}}
A suitable page for beginners about matrices is at: https://web.archive.org/web/20060819141930/http://www.gamedev.net/reference/programming/features/imageproc/page2.asp
The whole article starts on page: https://web.archive.org/web/20061019072001/http://www.gamedev.net/reference/programming/features/imageproc/