示例#1
0
        private void FilterMinimumDensityandRatio()
        {
            List <Blob> tmpBlobs;
            Blob        tmpBlob;

            tmpBlobs        = new List <Blob>();
            pBlue.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            //FIRST FILTERS OF PROPORTIONS FOR SQUARED BLOBS
            for (int i = 0; i < BlobFinder.Count; i++)
            {
                tmpBlob = BlobFinder.Blobs[i];

                if (tmpBlob.Density < 0.25)
                {
                    continue;
                }

                if (tmpBlob.Ratio < 0.15)
                {
                    continue;
                }

                tmpBlobs.Add(tmpBlob);
            }

            BlobFinder.Clear();
            BlobFinder.Blobs.AddRange(tmpBlobs.OrderBy(b => b.Centroid2Origin).ToList());
        }
示例#2
0
        private List <Triangle> FindTriangles()
        {
            Blob            one, two;
            double          distance;
            List <Triangle> triangles;
            List <Blob>     tmpBlobs;

            triangles = new List <Triangle>();
            tmpBlobs  = new List <Blob>();
            Triangle triangle;

            for (int index = 0; index < BlobFinder.Count; index++)
            {
                one      = BlobFinder.Blobs[index];
                triangle = new Triangle(one, Color.Red);
                tmpBlobs.Add(one);

                for (int next = index + 1; next < BlobFinder.Count; next++)
                {
                    two = BlobFinder.Blobs[next];

                    distance = Distance(one.Centroid, two.Centroid);

                    if ((distance / ((one.AvgSize + two.AvgSize) / 2)) > 10)//works
                    {
                        next = BlobFinder.Count;
                        BlobFinder.Remove(one);
                        tmpBlobs.Remove(one);
                        index--;
                    }
                    else
                    {
                        tmpBlobs.Add(two);
                        triangle.points.Add(two);
                        BlobFinder.Remove(two);
                        next--;
                        if (triangle.points.Count > 2)
                        {
                            triangles.Add(triangle);
                            next = BlobFinder.Count;
                        }
                    }
                }
            }

            BlobFinder.Clear();
            BlobFinder.Blobs.AddRange(tmpBlobs.ToList());

            return(triangles);
        }
示例#3
0
        private void FindBlobPairs()
        {
            List <Blob> tmpBlobs;
            float       maxR, minR;
            Blob        one, two, tmp;
            Point       p1, p2, p3, p4, midAB, midAC;

            tmpBlobs = new List <Blob>();
            maxR     = 0;
            minR     = 1000;

            //FINDS PAIRS OF BLOBS ONE INSIDE ANOTHER WITH CLOSE CENTROIDS
            for (int index = 0; index < BlobFinder.Count - 1; index++)
            {
                one = BlobFinder.Blobs[index];

                for (int t = index + 1; t < BlobFinder.Count; t++)
                {
                    two = BlobFinder.Blobs[t];

                    if (Math.Abs(one.Centroid2Origin - two.Centroid2Origin) > one.Diagonal / 3)
                    {
                        t = BlobFinder.Count;
                        BlobFinder.Blobs.Remove(one);
                        index--;
                        continue;
                    }//*/

                    if (one.Width < two.Width)
                    {
                        tmp = one;
                        one = two;
                        two = tmp;
                    }

                    midAB = MidPoint(one.A, one.B);
                    midAC = MidPoint(one.A, one.C);

                    p1 = MidPoint(one.A, midAB);
                    p2 = MidPoint(midAB, one.B);

                    p3 = MidPoint(one.A, midAC);
                    p4 = MidPoint(midAC, one.C);

                    if (
                        (two.Centroid.X > p1.X) && (two.Centroid.X < p2.X) &&
                        (two.Centroid.Y > p3.Y) && (two.Centroid.Y < p4.Y) &&
                        (one.Density / two.Density) < 1.3 && (two.Density / one.Density) > 1 &&
                        (one.Width / two.Width) > 1.5 && (one.Width / two.Width) < 3.5
                        )
                    {
                        tmpBlobs.Add(two);

                        if (two.Ratio > maxR)
                        {
                            maxR = two.Ratio;
                        }

                        if (two.Ratio < minR)
                        {
                            minR = two.Ratio;
                        }

                        BlobFinder.Blobs.Remove(one);
                        BlobFinder.Blobs.Remove(two);

                        index--;
                        t = BlobFinder.Count;
                    }
                    else
                    {
                        one = BlobFinder.Blobs[index];
                    }
                }
            }

            BlobFinder.Clear();
            BlobFinder.Blobs.AddRange(tmpBlobs.OrderBy(b => b.Centroid2Origin).ToList());
        }