我正在尝试使用OpenCV 3.0预定义方法connectedComponents()
从二进制图像中获取所有连接的标签。但是在执行操作之后。程序返回的标签总数仅为2,输出图像也没有显示任何内容,它完全是黑暗的。我甚至试过规范它,但我没有得到所需的输出。我做错了什么?
原始图片:
结果:
这是我正在使用的代码:
void featureExtract(){
Mat image = imread("4X4_b9.png",IMREAD_GRAYSCALE);
Mat output(image.size(),CV_16U);
int la = connectedComponents(image, output);
cout<<la<<endl;
Mat seeMyLabels;
normalize(output, seeMyLabels, 0, 255, NORM_MINMAX, CV_8U);
imshow("Labels", seeMyLabels);
// imshow("Output", output);
waitKey(0);
destroyAllWindows();
}