private static void drawContour(IList <PointF> controlPoints, Image <Bgr, byte> image) { const float CONTOUR_TENSION = 0; /******************** contour and control points *********************/ var pointIndices = CardinalSpline.GetEqualyDistributedPointIndices(controlPoints, CONTOUR_TENSION, 500); var points = CardinalSpline.InterpolateAt(controlPoints, CONTOUR_TENSION, pointIndices); var normals = new List <LineSegment2DF>(); var normalIndices = CardinalSpline.GetEqualyDistributedPointIndices(controlPoints, CONTOUR_TENSION, 100); foreach (var idx in normalIndices) { var pt = CardinalSpline.InterpolateAt(controlPoints, CONTOUR_TENSION, idx); var normalDirection = CardinalSpline.NormalAt(controlPoints, CONTOUR_TENSION, idx); var orientation = (int)Angle.ToDegrees(System.Math.Atan2(normalDirection.Y, normalDirection.X)); var normal = getLine(orientation, pt, 20); normals.Add(normal); } /******************** contour and control points *********************/ image.Draw(points.ToArray(), Bgr8.Blue, 3); image.Draw(controlPoints.Select(x => new CircleF(x, 3)), Bgr8.Red, 3); image.Draw(normals, Bgr8.Green, 3, false); }