1 | initial version |
What you actually need is:
Mat leafBinaryImage;
// Find binary image of leaf with holes in some way.
.....
// Find outer contour of your leaf
vector<vector<Point> > contours;
findContours(leafBinaryImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
// clean the image
leafBinaryImage.setTo(Scalar(0));
// draw contour of leaf in image
polylines(leafBinaryImage, contours, true, Scalar, CV_FILLED);
See here details of polylines and [findContours](http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#void findContours(InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset).
2 | No.2 Revision |
What you actually need is:
Mat leafBinaryImage;
// Find binary image of leaf with holes in some way.
.....
// Find outer contour of your leaf
vector<vector<Point> > contours;
findContours(leafBinaryImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
// clean the image
leafBinaryImage.setTo(Scalar(0));
// draw contour of leaf in image
polylines(leafBinaryImage, contours, true, Scalar, CV_FILLED);
See here details of polylines and [findContours](http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#void findContours(InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset).findContours.
3 | No.3 Revision |
What you actually need is:
Mat leafBinaryImage;
// Find binary image of leaf with holes in some way.
.....
// Find outer contour of your leaf
vector<vector<Point> > contours;
findContours(leafBinaryImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
// clean the image
leafBinaryImage.setTo(Scalar(0));
// draw contour of leaf in image
polylines(leafBinaryImage, contours, true, Scalar, Scalar(255), CV_FILLED);
See here details of polylines and findContours.