在对矩形进行检测后,如何提取斑点
本文关键字:何提取 提取 斑点 检测 | 更新日期: 2023-09-27 18:07:55
'//处理图像私有void ProcessImage(Bitmap位图){//锁定图像BitmapData =位图。LockBits (新建矩形(0,0,位图)宽度,bitmap.Height),ImageLockMode。读写,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.
现在我想从图像中提取用红色绘制的盘子。我该怎么做呢?
由于我的图像是二值图像,我已经应用了扩展来获得正确的LP候选,所有候选都在图像中被成功识别,但我无法使用ExtractBiggestBlob
方法提取它们。
请帮助。提前感谢。
对于非托管数组使用BitBlt GDI方法