|
@@ -2619,7 +2619,7 @@ namespace PaintDotNet.Adjust
|
|
|
}
|
|
|
}
|
|
|
//边缘
|
|
|
- if (x < border || x + width > src.Cols - border || y < border || y + height > src.Rows - -border - borderBottom)
|
|
|
+ if (x < border || x + width > src.Cols - border || y < border || y + height > src.Rows - border - borderBottom)
|
|
|
{
|
|
|
keyValuePairs.Add(h, 1);
|
|
|
}
|
|
@@ -2692,20 +2692,14 @@ namespace PaintDotNet.Adjust
|
|
|
|
|
|
|
|
|
//double c = contours[0].Length; //轮廓周长
|
|
|
- //double xa = Math.Sqrt(areaField1/ Math.PI) * 2;
|
|
|
+ //double xa = Math.Sqrt(areaField1 / Math.PI) * 2;
|
|
|
//double xp = c / Math.PI;
|
|
|
//int aa = Convert.ToInt32((xa / xp) * 1000);
|
|
|
|
|
|
+ double nc = Cv2.ArcLength(outArr.ToArray(), true) ;
|
|
|
|
|
|
- // InputArray contoursAll = InputArray.Create(AllFields[h - 1]);
|
|
|
- // List<OpenCvSharp.Point> outArr = new List<OpenCvSharp.Point>();
|
|
|
- // OutputArray hull = OutputArray.Create(outArr);
|
|
|
-
|
|
|
- // Cv2.ConvexHull(contoursAll, hull, true);
|
|
|
- // double nc = Cv2.ArcLength(outArr.ToArray(), true) / Math.PI;
|
|
|
-
|
|
|
- // double na = Math.Sqrt(areaField1 / Math.PI) * 2;
|
|
|
- //int aa = Convert.ToInt32((na / nc) * 1000);
|
|
|
+ double na = Math.Sqrt(areaField1 / Math.PI) * 2;
|
|
|
+ int aa = Convert.ToInt32((na / nc) * 1000);
|
|
|
List<OpenCvSharp.Point> listpoint = new List<OpenCvSharp.Point>();
|
|
|
Point2f[] point2F = rectR.Points();
|
|
|
foreach (var item in point2F)
|
|
@@ -2714,7 +2708,7 @@ namespace PaintDotNet.Adjust
|
|
|
}
|
|
|
rectListPoint.Add(listpoint);
|
|
|
rectList.Add(rectR);
|
|
|
- List<int> po = new List<int>() { x, y, width, height, areaField1, h, maxxx, maxyy, 1 };
|
|
|
+ List<int> po = new List<int>() { x, y, width, height, areaField1, h, maxxx, maxyy, 1 , (int)nc };
|
|
|
poList.Add(po);
|
|
|
}
|
|
|
}
|
|
@@ -2737,7 +2731,7 @@ namespace PaintDotNet.Adjust
|
|
|
|
|
|
#region 添加颗粒
|
|
|
|
|
|
- Mat MatAdd = new Mat(src.Size(), MatType.CV_8UC1);
|
|
|
+ Mat MatAdd = new Mat(src.Rows, src.Cols, MatType.CV_8UC1,new Scalar(0));
|
|
|
|
|
|
if (AddPontins != null && AddPontins.Count > 0)
|
|
|
{
|
|
@@ -2759,6 +2753,7 @@ namespace PaintDotNet.Adjust
|
|
|
{
|
|
|
Rect rect = Cv2.BoundingRect(contours[i]);
|
|
|
int areaField1 =Convert.ToInt32( Cv2.ContourArea(contours[i]));
|
|
|
+ int nc = Convert.ToInt32(Cv2.ArcLength(contours[i], true));
|
|
|
int x = rect.X;
|
|
|
int y = rect.Y;
|
|
|
int width = rect.Width;
|
|
@@ -2784,7 +2779,7 @@ namespace PaintDotNet.Adjust
|
|
|
}
|
|
|
rectListPoint.Add(listpoint);
|
|
|
rectList.Add(rectR);
|
|
|
- List<int> po = new List<int>() { x, y, width, height, areaField1, centroids.Height+i, maxxx, maxyy, 1 };
|
|
|
+ List<int> po = new List<int>() { x, y, width, height, areaField1, centroids.Height+i, maxxx, maxyy, 1 , nc };
|
|
|
poList.Add(po);
|
|
|
}
|
|
|
|