Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You will have to combine number of functions to do this, because existing blur functions don't use mask. Here an example (I assume that value of maskImage is 255 if pixel is relevant, and 0 if pixel is irrelevant):

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

You will have to combine number of functions to do this, because existing blur functions don't use mask. Here an example (I assume that value of maskImage is 255 if pixel is relevant, and 0 if pixel is irrelevant):

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

Last operation is combination of two images sourceImage and bluredImage. Values where maskImage was 255 will come from bluredImage, and values where maskImage was 0 will come from sourceImage.