// Triangulate the polygon.
        //
        // For a nice, detailed explanation of this method,
        // see Ian Garton's Web page:
        // http://www-cgrl.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Ian/cutting_ears.html
        public List<Triangle> Triangulate()
        {
            // Copy the points into a scratch array.
            PointF[] pts = new PointF[Points.Length];
            Array.Copy(Points, pts, Points.Length);

            // Make a scratch polygon.
            Polygon pgon = new Polygon(pts);

            // Orient the polygon clockwise.
            pgon.OrientPolygonClockwise();

            // Make room for the triangles.
            List<Triangle> triangles = new List<Triangle>();

            // While the copy of the polygon has more than
            // three points, remove an ear.
            while (pgon.Points.Length > 3)
            {
                // Remove an ear from the polygon.
                pgon.RemoveEar(triangles);
            }

            // Copy the last three points into their own triangle.
            triangles.Add(new Triangle(pgon.Points[0], pgon.Points[1], pgon.Points[2]));

            return triangles;
        }
 /// <summary>
 /// Process image looking for matchings with specified template.
 /// </summary>
 /// 
 /// <param name="image">Source image to process.</param>
 /// <param name="template">Template image to search for.</param>
 /// <param name="searchZone">Rectangle in source image to search template for.</param>
 /// 
 /// <returns>Returns array of found template matches. The array is sorted by similarity
 /// of found matches in descending order.</returns>
 /// 
 /// <exception cref="UnsupportedImageFormatException">The source image has incorrect pixel format.</exception>
 /// <exception cref="InvalidImagePropertiesException">Template image is bigger than source image.</exception>
 /// 
 //TRL
 public TemplateMatch[] ProcessImage(Bitmap image, Bitmap template, Rectangle searchZone, List<PointF>PCocDiamond)
 {
     //polarea is a string "|" delimited with 4 point coordinates "topX,topY|leftX,leftY|bottomX,bottomY|rightX,rightY"
     COCDiamond = new Polygon(PCocDiamond.ToArray());
     return ProcessImage(image, template, searchZone);
 }