Ask Your Question
0

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

asked 2016-04-10 21:38:03 -0600

Solace gravatar 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.

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-04-10 22:44:17 -0600

Tetragramm gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-10 21:38:03 -0600

Seen: 473 times

Last updated: Apr 10 '16