【发布时间】:2017-06-25 13:46:29
【问题描述】:
我正在使用findContours() 和drawContours() 方法在我的二进制图像中查找轮廓。然而,这是我的输出:
如果我进一步阈值我的图像,例如矩形变得模糊,那么内部是可见的(注意外部和内部曲线在左下角合并):
你能解释一下这个以及如何解决它吗?
以下是我的代码 sn-p:
void cb_thresh(int,void*)
{vector< vector<Point> > contours;
vector<Vec4i> hierarchy;
threshold(src, thr,threshval, 255,THRESH_BINARY);
namedWindow("threshold",CV_WINDOW_NORMAL);
imshow("threshold",thr);
findContours( thr, contours, hierarchy,CV_RETR_LIST, CV_CHAIN_APPROX_NONE ); // Find the contours in the image
Scalar color( 255,255,255);
for( int i = 0; i< contours.size(); i++ ) // iterate through each contour
{
drawContours(thr, contours,i, color, CV_FILLED, 8, hierarchy );
}
namedWindow("dst",CV_WINDOW_NORMAL);
imshow("dst",thr);
}
请注意我已经删除了轮廓的层次结构。
【问题讨论】:
-
我尝试更改轮廓提取方法,但在所有 4 种检索方法中得到相同的输出。
-
你想要的输出是什么?
标签: opencv opencv3.0 contour opencv3.1 opencv-contour