Compute() public method

public Compute ( ) : void
return void
コード例 #1
0
ファイル: BlobDetector.cs プロジェクト: isaveu/HandsFree
 public void Compute(ref Image <Gray, byte> imageSource, int i, int j)
 {
     gray  = imageSource.Data[j, i, 0];
     x0    = i; y0 = j;
     image = imageSource;
     blob  = new Blob();
     addToBlob(i, j);
     for (int k = 0; k < blob.Count; k++)
     {
         pt = blob.Data[k];
         if (pt.X > 0 && pt.X < imageSource.Width - 1 && pt.Y > 0 && pt.Y < imageSource.Height - 1)
         {
             x = pt.X - 1; y = pt.Y - 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X; y = pt.Y - 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X + 1; y = pt.Y - 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X - 1; y = pt.Y;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X + 1; y = pt.Y;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X - 1; y = pt.Y + 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X; y = pt.Y + 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
             x = pt.X + 1; y = pt.Y + 1;
             if (image.Data[y, x, 0] == gray)
             {
                 addToBlob(x, y);
             }
         }
     }
     blob.Compute();
     Blobs.Add(blob);
 }
コード例 #2
0
ファイル: BlobDetector.cs プロジェクト: Ractiv/HandsFree
        public void Compute(ref Image<Gray, byte> imageSource, byte grayToDetect)
        {
            gray = grayToDetect;
            image = imageSource.Clone();
            Blobs = new List<Blob>();
            BlobMaxArea = new Blob();
            for (int j = imageSource.Height - 1; j >= 0; j--)
                for (int i = imageSource.Width - 1; i >= 0; i--) {
                    if (image.Data[j, i, 0] == gray) {

                        blob = new Blob();
                        addToBlob(i, j);
                        for (int k = 0; k < blob.Count; k++) {

                            pt = blob.Data[k];
                            if (pt.X > 0 && pt.X < imageSource.Width - 1 && pt.Y > 0 && pt.Y < imageSource.Height - 1) {

                                x = pt.X - 1; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X + 1; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X - 1; y = pt.Y;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X + 1; y = pt.Y;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X - 1; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                                x = pt.X + 1; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray) addToBlob(x, y);
                            }
                        }

                        blob.Compute();
                        Blobs.Add(blob);
                        if (blob.Area > BlobMaxArea.Area) BlobMaxArea = blob;
                    }
                }
        }
コード例 #3
0
ファイル: BlobDetector.cs プロジェクト: sohguodong/HandsFree
        public void Compute(ref Image<Gray, byte> imageSource, int i, int j)
        {
            gray = imageSource.Data[j, i, 0];
            x0 = i;
            y0 = j;
            image = imageSource;
            blob = new Blob();
            addToBlob(i, j);

            for (int k = 0; k < blob.Count; k++)
            {
                pt = blob.Data[k];

                if (pt.X > 0 && pt.X < imageSource.Width - 1 && pt.Y > 0 && pt.Y < imageSource.Height - 1)
                {
                    x = pt.X - 1;
                    y = pt.Y - 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X;
                    y = pt.Y - 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X + 1;
                    y = pt.Y - 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X - 1;
                    y = pt.Y;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X + 1;
                    y = pt.Y;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X - 1;
                    y = pt.Y + 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X;
                    y = pt.Y + 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);

                    x = pt.X + 1;
                    y = pt.Y + 1;

                    if (image.Data[y, x, 0] == gray)
                        addToBlob(x, y);
                }
            }

            blob.Compute();
            Blobs.Add(blob);
        }
コード例 #4
0
ファイル: BlobDetector.cs プロジェクト: isaveu/HandsFree
        public void Compute(ref Image <Gray, byte> imageSource, byte grayToDetect)
        {
            gray        = grayToDetect;
            image       = imageSource.Clone();
            Blobs       = new List <Blob>();
            BlobMaxArea = new Blob();
            for (int j = imageSource.Height - 1; j >= 0; j--)
            {
                for (int i = imageSource.Width - 1; i >= 0; i--)
                {
                    if (image.Data[j, i, 0] == gray)
                    {
                        blob = new Blob();
                        addToBlob(i, j);
                        for (int k = 0; k < blob.Count; k++)
                        {
                            pt = blob.Data[k];
                            if (pt.X > 0 && pt.X < imageSource.Width - 1 && pt.Y > 0 && pt.Y < imageSource.Height - 1)
                            {
                                x = pt.X - 1; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X + 1; y = pt.Y - 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X - 1; y = pt.Y;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X + 1; y = pt.Y;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X - 1; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                                x = pt.X + 1; y = pt.Y + 1;
                                if (image.Data[y, x, 0] == gray)
                                {
                                    addToBlob(x, y);
                                }
                            }
                        }

                        blob.Compute();
                        Blobs.Add(blob);
                        if (blob.Area > BlobMaxArea.Area)
                        {
                            BlobMaxArea = blob;
                        }
                    }
                }
            }
        }