private static IList <PointF> findContour(Gray <byte>[,] templateImg) { var contour = templateImg.FindContour(minGradientStrength: 150).Select(x => (PointF)x).ToList(); /*********** cut bottom border and shift contour beginning to the first non-border point ***************/ int firstIdx = -1; int lastIdx = -1; for (int i = 0; i < contour.Count; i++) { if (contour[i].Y == (templateImg.Height() - 1)) { if (firstIdx == -1) { firstIdx = i; } lastIdx = i; } } //return contour; return(new CircularList <PointF>(contour).GetRange(lastIdx, contour.Count - (lastIdx - firstIdx + 1))); }