Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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);

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);