Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

I have an image with arbitrary area (the boundary is shown in gray):

enter image description here

I would like to blur just the image within boundaries.

Ordinary blur causes the background proliferating to image and vice versa. This results in dark areas near boundaries of the image:

enter image description here

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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 & mask) / filter(mask)) & mask
share|improve this answer
    
Thanks. This is equivalent to blurring both image layer and alpha mask layer, right? –  Libor Dec 31 '12 at 0:08
    
I see it as a filter that only averages over the area inside the mask. But yes, you can also see it as blurring a premultilpied alpha image, then convert back to normal RGBA. –  nikie Dec 31 '12 at 9:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.