14
Cross-correlation filtering
Let’s write this down as an equation.  Assume the averaging window is (2k+1)x(2k+1):
We can generalize this idea by allowing different weights for different neighboring pixels:
This is called a cross-correlation operation and written: 
H is called the “filter,”  “kernel,”  or “mask.”
The above allows negative filter indices.  When you implement need to use:  H[u+k,v+k] instead of H[u,v]