The code is doing convolution on 3x3 grids and averaging the values over the 9 cells. When applied to images, it blurs the image.
suninhouse
Following up on @thread17's comment, it is averaging the values since that is how the weights are being defined; in other words, if weights are defined differently, then it may be some other linear combinations but not necessarily averaging.
mkarra
To reiterate, the operation on the image: for every output pixel, the value of the output pixel is the weighted sum of the 9 input pixels surrounding that location -- 3x3 box blur.
The code is doing convolution on 3x3 grids and averaging the values over the 9 cells. When applied to images, it blurs the image.