赞
踩
- Mat remove_block(double minarea, Mat& src){
- CvSeq* contour = NULL;
- double tmparea = 0.0;
- CvMemStorage* storage = cvCreateMemStorage(0);
- //const char* tmpaddsum1 = tmp_string.c_str();
-
- //IplImage* img_src = cvLoadImage(tmpaddsum1, CV_LOAD_IMAGE_ANYCOLOR);
- IplImage* img_src = &IplImage(src);
- IplImage* img_Clone = cvCloneImage(img_src);
- //访问二值图像每个点的值
- uchar *pp;
- IplImage* img_dst = cvCreateImage(cvGetSize(img_src), IPL_DEPTH_8U, 1);
-
- //-----搜索2值图中的轮廓,并从轮廓树中删除面积小于minarea的区域-----//
- //CvScalar color = cvScalar(255, 0, 0);//CV_RGB(128,0,0)
- CvContourScanner scanner = NULL;
- scanner = cvStartFindContours(img_src, storage, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE, cvPoint(0, 0));
- //开始遍历轮廓树
- CvRect rect;
-
- while (contour = cvFindNextContour(scanner)){
- tmparea = fabs(cvContourArea(contour));
- rect = cvBoundingRect(contour, 0);
-
- if (tmparea < minarea){
- //当连通区
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。