滤出轮廓中较大或者较小的

 //查找轮廓    
    int cmin = 10;     // 轮廓最短值
    int cmax = 1000;    // 轮廓最长值
    findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );     
    std::vector<std::vector<cv::Point>>::const_iterator itc = contours.begin();
    while (itc != contours.end())   //清楚图像的噪声点
    {
        // 移除过长或过短的轮廓
        if (itc->size() < cmin || itc->size() > cmax) 
            itc = contours.erase(itc);
        else
            ++itc;
    }

 

posted @ 2018-01-24 19:25  体育.委员  阅读(145)  评论(0编辑  收藏  举报