如果我有一个3x3的二进制图像,并且在位置(x,y):(0,0),(0,1),(1,0),(1,1)有轮廓,通过
这个轮廓是正方形,所以面积为2*2 = 4
那么为什么ContourArea等于1?
我正在使用EmguCV,以下是我的代码:
findContours
方法获取轮廓。我想获得这个轮廓的面积:
- 使用CountNonZero: 4
- 使用contourArea: 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);