The Average (mean) filter smooths image data, thus eliminating
noise. This filter performs spatial filtering on each individual
pixel in an image using the grey level values in a square or
rectangular window surrounding each pixel.
For example:
a1 a2 a3
a4 a5 a6 3x3 filter window
a7 a8 a9
The average filter computes the sum of all pixels in the filter
window and then divides the sum by the number of pixels in the
filter window:
Filtered pixel = (a1 + a2 + a3 + a4 ... + a9) / 9
NOTE: In order to filter pixels located near the edges of the image,
edge pixel values are replicated to give sufficient data.