Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Applying filter with a Mask

I have an image and a mask, where I want to do filter/blur operations only at the region where the mask is white i.e the mask has value 255 and not where mask has 0.

I tried using these operation :

erode(maskImage,maskImage,Mat()); // values near irrelevant pixels should not be changed
blur(sourceImage,bluredImage,Size(3,3));
bluredImage = sourceImage + ((bluredImage-sourceImage) & maskImage);

But the & operation cannot be performed in images with different channels.

And when I tried with the accepted answer from here http://answers.opencv.org/question/3031/smoothing-with-a-mask/ it gave me completely black image.

So how can I do operations with a mask as a parameter?