Ask Your Question

Revision history [back]

click to hide/show revision 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).

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.

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.