I'm doing a binary thresholding on an image using opencv, while moving or animating for example a circle on a binary image, there are few noise that appears around the moveable object. An image to illustrate what I mean is attached. How can I get rid of those artifacts?
Asked
Active
Viewed 407 times
0

acraig5075
- 10,588
- 3
- 31
- 50

Moaz ELdeen
- 249
- 2
- 3
- 10
-
Does OpenCV have a way of determining which bits are connected? If so, maybe all connected bits that aren't circular could be eliminated? – user1118321 Aug 01 '12 at 14:35
-
Extrapolating off user1118321's idea, you could find the bounds of the circle, then cull outside of that. – ssube Aug 01 '12 at 14:46
-
1Is that artifact due to frame differencing? You mentioned that it's a moving circle. If so, try 3-frame differencing. It goes like this: `f = abs((frame1 - frame0) * (frame1 - frame2))` – paddy Aug 01 '12 at 14:52
-
Yes due to drame differencing – Moaz ELdeen Aug 01 '12 at 15:22
2 Answers
0
If you want to get rid of object that are non circles, you can filter contours according to several metrics this seems to be a good starting link. In your case, you could find all contours and keep only the ones with a high circularity and a small aspect ratio. You can go further and calculates metrics such as area/area_of_the_convex_hull. This one should be one for your circle.
Good luck
ps: this pdf seems more exhaustive.

Quentin Geissmann
- 2,240
- 1
- 21
- 36
0
You could try to apply several cycles of the erosion algorithm (until there is only one object left) followed by same number of cycles of the dilation algorithm (the erosion/dilation pair is called opening)
See here: http://en.wikipedia.org/wiki/Mathematical_morphology

Paolo Brandoli
- 4,681
- 26
- 38