0
votes

` // Process image private void ProcessImage(Bitmap bitmap) { // lock image BitmapData bitmapData = bitmap.LockBits( new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat);

        // step 2 - locating objects
        BlobCounter blobCounter = new BlobCounter();
        blobCounter.FilterBlobs = true;
        blobCounter.MinHeight = 5;
        blobCounter.MinWidth = 5;

        blobCounter.ObjectsOrder = ObjectsOrder.Size;
        blobCounter.ProcessImage(bitmapData);
        Blob[] blobs = blobCounter.GetObjectsInformation();
        bitmap.UnlockBits(bitmapData);

        // step 3 - check objects' type and highlight
        SimpleShapeChecker shapeChecker = new SimpleShapeChecker();

        Graphics g = Graphics.FromImage(bitmap);
        Pen redPen = new Pen(Color.Red, 2);       // quadrilateral

        for (int i = 0, n = blobs.Length; i < n; i++)
        {
            List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);

            List<IntPoint> corners;
            // use the shape checker to extract the corner points
            if (shapeChecker.IsQuadrilateral(edgePoints,out corners ))
            {
                // only do things if the corners form a rectangle
                if (shapeChecker.CheckPolygonSubType(corners) == PolygonSubType.Rectangle)
                {

                    g.DrawPolygon(redPen, ToPointsArray(corners));

                }
            }
        }


        redPen.Dispose();
        g.Dispose();
        // put new image to clipboard
        Clipboard.SetDataObject(bitmap);
        // and to picture box
        pictureBox1.Image = bitmap;
       }


    }`In [this link][0] array of rectangles was detected. Now, my question is how do I extract the rectangle from the image. My scenario is I detect the rectangular License plate of a car (colored image converted to binary  ) in the image and draw with red the location of the plate.

Now I want to extract that plate that is drawn in red from the image. How do i do that.

Since my image is a binary image, I had applied dilation to get the correct LP candidate, all candidates are being successfully recognized in the image, but i cannot extract them using ExtractBiggestBlob method.

Please help. Thanks in advance.

1
Provide code you've done.Irshad
@Irshad PFA the code. I want to extract the rectangle that is drawn in red in the image with the g. drawpolygon method. Attaching the image as well for sample . Thanks in advance for helping.Swati Sinha

1 Answers

0
votes

For unmanaged arrays use BitBlt GDI methods.