Written out for a square 3×3 window (the default Kernel shape is Disk) at output position (x, y), the average is:
O(x, y) = (1/9) · [I(x−1,y−1) + I(x,y−1) + I(x+1,y−1) + I(x−1,y) + I(x,y) + I(x+1,y) + I(x−1,y+1) + I(x,y+1) + I(x+1,y+1)]
Two computational notes. First, the box is separable: the 2D N×N box is the outer product of two 1D boxes of length N, so filtering rows and then columns costs O(WHN) instead of O(WHN²). Second, a running sum can slide with the window, adding the entering column and subtracting the leaving one. That brings the cost to O(WH) whatever the window size, and most production implementations use it.