public bool IsCircle(Shape shape) { int maxX = 0, minX=image.GetLength(0)-1, maxY=0, minY=image.GetLength(1)-1; for(int x = 0; x < image.GetLength(0); x++) for (int y = 0; y < image.GetLength(1); y++) { if (image[x, y] == shape.Marker) { if (x > maxX) maxX = x; if (x < minX) minX = x; if (y > maxY) maxY = y; if (y < minY) minY = y; } } double xRad = (maxX - minX)/2; double yRad = (maxY - minY)/2; if (xRad <= 0 || yRad <= 0 || (Math.Abs(1 - xRad/yRad)) > 0.12) { MessageBox.Show(String.Format("m:{0}, 1.: {1}", shape.Marker, (Math.Abs(1 - xRad/yRad).ToString()))); return false; } double rad = (xRad + yRad)/2; double per = 2*Math.PI*rad; double shapePer = (double) shape.GetOutPerimenter(); double shapeSq = (double) shape.GetSquareWithChildren(); double sq = Math.PI * rad * rad; Console.WriteLine(sq+shapeSq); //if ((Math.Abs(1 - per / (shapePer))) > 0.1) // return false; if ((Math.Abs(1 - sq / (shapeSq))) > 0.26) { MessageBox.Show(String.Format("m:{0}, 2.: {1}", shape.Marker, (Math.Abs(1 - sq / (shapeSq))))); return false; } //if ((Math.Abs(1 - shape.Elongation)) > 0.15) // return false; //if (shape.ChildShapes == null || shape.ChildShapes.Count == 0) // return false; return true; }