Blurring Non-Uniform Areas
One simple solution would be to create a binary (0/255) mask of the area you want to blur. Then blur the source image BITWISE AND mask, blur the mask with the same filter and divide them. As pseudocode:

(filter(source &amp; mask) / filter(mask)) &amp; mask