It sounds like you're sampling outside the input image's DOD. Samples outside that region are treated as transparent black. You should consider adding functionality similar to "Repeat Edge Pixels" in AE's Box Blur. Would you please verify that the behavior you're seeing is similar to AE's Box Blur when "Repeat Edge Pixels" is not enabled. I hope that answers your questions. Please let me know if I've missed something here.
Thanks for the reply, but that's not the issue. What I was seeing was the blur itself being darkened, rather than the edges of the region. The image being blurred has an alpha channel and it was those alpha edges that were being premulted with black.
I think I found the solution by dividing the colour of the blurred pixels by the alpha of the blurred pixels if greater than 0 (unpremultiplying, assuming the background is black).
Does that sound right?
yes, After Effects is pre-multiplying with Alpha. This is usually what you want to do in a convolution, but in your case doing the un-premultiply would be correct.