0

I am working with OpenCV for android and trying to create a shape mask from the found contours. I have found contours of an object using findContours of only external contours, such as:

Contours of a fork

I want to create a mask in order to seperate the object from the background. For the example of the fork, it should be something like this:

Desired mask for the fork

I tried to use fillPoly to accomplish it, but the problem is that the contours are not connected.

I also tried to connect them into one contour but the connections are not right. Is there a way to get the general shape of the contours and create this mask?

Thanks.

Antonio
  • 19,451
  • 13
  • 99
  • 197
Sapiro
  • 11
  • 1
  • Similar question [here](http://stackoverflow.com/q/21469409/2436175), you can get some hints from the comments there. – Antonio May 10 '16 at 13:12
  • Try to apply some filtering on the image before finding the contour, such as Canny edge detection. You need to have this contour whole. After that, check [this](http://www.bytefish.de/blog/extracting_contours_with_opencv/) article – gcw May 10 '16 at 18:39
  • I have edge detection with Canny before finding the contours. I also already tried to use approxPolyDP to have the polygon of the shape. Thanks – Sapiro May 11 '16 at 14:04

0 Answers0