1
我使用findContours()
和drawContours()
方法來查找我的二進制圖像中的輪廓。然而,這是我的輸出:找不到嵌套的輪廓
如果我進一步閾我的圖像,如矩形變得模糊,則內是可見的(注意外部和內部曲線在底部合併左):
請問您能解釋一下以及如何解決?
以下是我的代碼片段:
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種檢索方法中獲得相同的輸出。 –
你想要的輸出是什麼? – Micka