0

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? enter image description here

acraig5075
  • 10,318
  • 3
  • 30
  • 48
Moaz ELdeen
  • 239
  • 2
  • 3
  • 9
  • 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
  • 1
    Is 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 Answers2

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,190
  • 1
  • 19
  • 34
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,572
  • 24
  • 37