This may be clearer if you try running a convolution (i.e. the filters.correlate line) and look at the output. The kernel weights the output by a factor equal to the sum of the kernel, so we have to divide this out.