First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered Feb 2 '15

Michael Burdinov gravatar image

What you actually need is to find outermost contours in black-white image and draw them . This way you won't have holes in objects. First task can be done by findContours function. Second, by drawContours function.

vector<vector<Point> > contours;
findContours(bwImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
drawContours(bwImage, contours, -1, Scalar(255), CV_FILLED);
click to hide/show revision 2
No.2 Revision

What you actually need is to find outermost contours in black-white image and then draw them . them. This way you won't have holes in objects. First task can be done by findContours function. Second, by drawContours function.

vector<vector<Point> > contours;
findContours(bwImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
drawContours(bwImage, contours, -1, Scalar(255), CV_FILLED);