【发布时间】:2016-04-27 09:11:03
【问题描述】:
cv::Mat thr;
std::vector<std::vector<cv::Point> > contours;
std::vector<std::vector<cv::Vec4i> > hierarchy;
int largest_area = 0;
int largest_contour_index = 0;
cv::findContours( thr, contours, hierarchy,CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); // Find the contours in the image
for( int i = 0; i < contours.size(); i++ ) // iterate through each contour.
{
double a = contourArea( contours[i], false ); // Find the area of contour
if(a > largest_area)
{
largest_area = a;
largest_contour_index = i; // Store the index of largest contour
}
}
找到最大轮廓的索引后该怎么办?如何删除所有其他轮廓及其内部区域? 图像是二进制的(cv::Mat thr)。只是带有白色区域的黑色背景。 谢谢。
【问题讨论】:
标签: c++ opencv subtraction areas opencv-contour