# Using OpenCV4Android, how to blur a part of an image?

I am using inRange() function of OpenCV4Android to detect a colored blob in an image. Then I am using drawContours() to draw the contours around the selected object.

What I want is that when the contour is drawn, the image outside the contour (i.e. the part which is not a part of the contour or detected colored blob/object) should get a little blur.

How can I do that? I am not asking necessarily for code. If you can tell me what function(s) to use, or how to go about it, I'll look into the API's and do it. Thank you.

edit retag close merge delete

Sort by » oldest newest most voted

Blur the whole image with either blur (a box filter) or gaussianBlur, then do a copyTo from the original to the blurred image with a mask. The mask should be 255 where you want the copy, and 0 elsewhere.

This may leave small amounts near the edge where the inside has bled over into the rest of the image. If that's a problem, there are more complicated ways we could try.

more

Official site

GitHub

Wiki

Documentation