public static Polygon ToPolygon(this AForge.Imaging.Blob blob, AForge.Imaging.BlobCounterBase counter, AForge.Math.Geometry.IConvexHullAlgorithm hullAlgorithm) { List<AForge.IntPoint> leftPoints, rightPoints, edgePoints; counter.GetBlobsLeftAndRightEdges(blob, out leftPoints, out rightPoints); edgePoints = leftPoints.Union(rightPoints).ToList(); var hull = hullAlgorithm.FindHull(edgePoints); // blob's convex hull return new Polygon(blob.Rectangle, from point in hull select point.ToPoint(), new System.Drawing.Point((int)(blob.CenterOfGravity.X), (int)(blob.CenterOfGravity.Y))); }