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