Ejemplo n.º 1
0
 private bool mergeOverlap()
 {
     for (int n = 0; n < Lines.Count; n++)
     {
         Line l1 = Lines[n];
         for (int i = 0; i < Lines.Count; i++)
         {
             if (i != n)
             {
                 Line l2 = Lines[i];
                 if (ShapeMaker.doLinesIntersect(l1, l2))
                 {
                     Lines.RemoveAt(Math.Max(i, n));
                     Lines.RemoveAt(Math.Min(i, n));
                     if (l1.P1.X < l2.P1.X)
                     {
                         Lines.Add(new Line(l1.P1, l2.P2));
                     }
                     else
                     {
                         Lines.Add(new Line(l2.P1, (l1.P2.X < l2.P2.X ? l2.P2 : l1.P2)));
                     }
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        private void ProcessImage(PictureBox p)
        {
            pictureBox1.Visible = false;
            pictureBox3.Visible = false;
            pictureBox2.Visible = false;
            p.Visible           = true;

            var f     = new LineFinder();
            var lines = f.ScanBitmap(p.Image as Bitmap);

            var          s          = new ShapeMaker();
            List <Point> maxPolygon = new List <Point>();

            for (int n = 0; n < lines.Count * 2; n++)
            {
                var polygon = s.FindContour(lines, n);
                if (polygon.Count > maxPolygon.Count)
                {
                    maxPolygon = polygon;
                }
                if (n == 10)
                {
                    break;
                }
            }

            draw(lines, maxPolygon);
        }