AForge.Imaging.Filters.Closing.ApplyInPlace C# (CSharp) Метод

ApplyInPlace() публичный Метод

Apply filter to an unmanaged image or its part.
The method applies the filter directly to the provided source image.
Unsupported pixel format of the source image.
public ApplyInPlace ( UnmanagedImage image, Rectangle rect ) : void
image UnmanagedImage Unmanaged image to apply filter to.
rect System.Drawing.Rectangle Image rectangle for processing by the filter.
Результат void
        public void ApplyInPlace( UnmanagedImage image, Rectangle rect )
        {
            dilatation.ApplyInPlace( image, rect );
            errosion.ApplyInPlace( image, rect );
        }
    }

Same methods

Closing::ApplyInPlace ( Bitmap image ) : void
Closing::ApplyInPlace ( Bitmap image, Rectangle rect ) : void
Closing::ApplyInPlace ( BitmapData imageData ) : void
Closing::ApplyInPlace ( BitmapData imageData, Rectangle rect ) : void
Closing::ApplyInPlace ( UnmanagedImage image ) : void

Usage Example

Пример #1
1
        private Bitmap processImage(Bitmap img)
        {
            //Generate closing structural element
            short[,] structEl = new short[13, 13];

            for (int i = 0; i < 13; i++)
                for (int j = 0; j < 13; j++)
                    if ((i - 6) * (i - 6) + (j - 6) * (j - 6) < 64)
                        structEl[i, j] = 1;
                    else
                        structEl[i, j] = -1;

            //Initialize filters
            HSLFiltering borderFind = new HSLFiltering();
            Closing borderClose = new Closing(structEl);
            Invert invert = new Invert();
            Grayscale grayFilter = new Grayscale(0, 0, 1.0);
            Threshold bwFilter = new Threshold(1);

            PointedColorFloodFill blackout = new PointedColorFloodFill();
            blackout.Tolerance = Color.FromArgb(0, 0, 0);
            blackout.FillColor = Color.FromArgb(0, 0, 0);

            ExtractBiggestBlob getgame = new ExtractBiggestBlob();
            getgame.OriginalImage = new Bitmap(img);

            GrayscaleToRGB colorFilter = new GrayscaleToRGB();

            //Color determined with ColorProbe.
            borderFind.Hue        = new IntRange(190, 200);
            borderFind.Saturation = new Range(0.6f, 0.8f);
            borderFind.Luminance  = new Range(0.6f, 1.0f);

            borderFind.ApplyInPlace(img);
            borderClose.ApplyInPlace(img);
            img = grayFilter.Apply(img);
            bwFilter.ApplyInPlace(img);
            invert.ApplyInPlace(img);
            img = colorFilter.Apply(img);

            blackout.StartingPoint = new AForge.IntPoint(0, 0);
            blackout.ApplyInPlace(img);

            img = getgame.Apply(img);

            int tilesx = img.Width / 56;
            int tilesy = img.Height / 56;
            int offsetx = 56 * (int)(tilesx - img.Width / 56.0);
            int offsety = 56 * (int)(tilesy - img.Height / 56.0);

            if ((Math.Abs(offsetx) > 11) || (Math.Abs(offsety) > 11))
                    throw new GameNotFoundException();

            List<IntPoint> corners = new List<IntPoint>();
            Dictionary<IntPoint, Bitmap> tiles = new Dictionary<IntPoint, Bitmap>();
            SimpleQuadrilateralTransformation tileXtract = new SimpleQuadrilateralTransformation();

            for (int j = 0; j < tilesy; j++)
                for (int i = 0; i < tilesx; i++)
                {
                    corners.Add(new IntPoint(offsetx + i * 56,           offsety + j * 56          ));
                    corners.Add(new IntPoint(offsetx + i * 56,           offsety + (j + 1) * 56 - 1));
                    corners.Add(new IntPoint(offsetx + (i + 1) * 56 - 1, offsety + (j + 1) * 56 - 1));
                    corners.Add(new IntPoint(offsetx + (i + 1) * 56 - 1, offsety + j * 56          ));

                    tileXtract.SourceQuadrilateral = corners;

                    tiles.Add(new IntPoint(i, j), tileXtract.Apply(img));

                    corners.Clear();
                }

            img = (Bitmap)Properties.Resources.ResourceManager.GetObject("cb");

            /*Graphics g = Graphics.FromImage(img);
            Pen bluePen = new Pen(Color.Blue, 2);

            for (int i = 0, n = blobs.Length; i < n; i++)
            {
                List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
                if (edgePoints.Count > 1)
                {
                    List<IntPoint> corners = PointsCloud.FindQuadrilateralCorners(edgePoints);
                    g.DrawPolygon(bluePen, ToPointsArray(corners));
                }
            }

            bluePen.Dispose();
            g.Dispose();
            */

            return img;
        }
All Usage Examples Of AForge.Imaging.Filters.Closing::ApplyInPlace