SMOOTHPOLYLINE Smooth a polyline using local averaging.

   RES = smoothPolygon(POLY, M)
   POLY contains the polyline vertices, and M is the size of smoothing
   (given as the length of the convolution window).
   Extremities of the polyline are smoothed with reduced window (last and
   first vertices are kept identical, second and penultimate vertices are
   smoothed with 3 values, etc.).

   Example
     img = imread('circles.png');
     img = imfill(img, 'holes');
     contours = bwboundaries(img');
     poly = contours{1}(201:500,:);
     figure; drawPolyline(poly, 'b'); hold on;
     poly2 = smoothPolyline(poly, 21);
     drawPolygon(poly2, 'm');

   See also
     polygons2d, smoothPolygon, simplifyPolyline, resamplePolyline

Package: matgeom