【发布时间】:2020-08-01 02:46:06
【问题描述】:
如果我有一个 3x3 的二值图像并且在位置 (x,y) 中有一个轮廓:(0,0), (0,1), (1,0), (1,1)
我通过findContours 方法得到轮廓。
我想得到这个轮廓的面积:
- 使用 CountNonZero:4
- 轮廓区域:1
- 与 Moment M00: 1
什么是正确答案,它们之间有什么区别?
这个轮廓是正方形的,所以面积是 2*2 = 4
那么为什么 ContourArea 等于 1?
我正在使用 EmguCV,这是我的代码:
VectorOfVectorOfPoint cont = new VectorOfVectorOfPoint();
Image<Gray, byte> img = new Image<Gray, byte>(3,3);
img[0, 0] = new Gray(255);
img[0, 1] = new Gray(255);
img[1, 0] = new Gray(255);
img[1, 1] = new Gray(255);
CvInvoke.FindContours(img, cont, null, Emgu.CV.CvEnum.RetrType.External, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
Moments m = CvInvoke.Moments(cont[0], true);
Console.WriteLine(CvInvoke.ContourArea(cont[0]));
CvInvoke.Imshow("ss", img);
CvInvoke.WaitKey(0);
【问题讨论】:
标签: opencv image-processing emgucv opencv-contour opencv3.1