从车辆图像中提取车牌

Mr.*_*oob 2 c# image-processing aforge anpr

我正在开发一个anpr应用程序,我已设法从车辆图像中找到车牌区域. 以下是我提取的车牌图像

当我将这个图像输入到tesseract OCR引擎时,似乎在"C"之前检测到一个字符"L",所以我想要取出号牌区域周围剩余的黑色像素.是否有一种特殊的方法可以解决这个问题?我在这种情况下使用aforge.net库

干杯

And*_*son 5

半自动移除编号牌周围黑色像素区域的一种方法是将PointedColorFloodFill滤镜应用四次,将填充起点放在图像的四个角上.

下面是一些示例代码,我将过滤器应用于上述问题的车牌图像副本(裁剪以删除白色边框):

var filter = new PointedColorFloodFill();
filter.FillColor = Color.White;
filter.Tolerance = Color.FromArgb(60, 60, 60);

filter.StartingPoint = new IntPoint(0, 0);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(image.Size.Width - 1, 0);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(image.Size.Width - 1, image.Size.Height - 1);
filter.ApplyInPlace(image);
filter.StartingPoint = new IntPoint(0, image.Size.Height - 1);
filter.ApplyInPlace(image);
Run Code Online (Sandbox Code Playgroud)

从四个角完成过滤后提供以下图像:

充满洪水的车牌

您可能希望尝试更浅灰色的填充颜色和不同的公差,但此示例至少可以提供合理的起点.

更新我偶然发现了BradleyLocalThresholding过滤器,它可以为您的OCR识别提供更好的起点.此滤镜只能应用于8bpp图像,您可以通过首先在原始图像上应用灰度滤镜来解决这些问题.如果在PointedColorFloodFill代码之前添加以下四行:

var grayFilter = new Grayscale(0.3, 0.3, 0.3);
var image = grayFilter.Apply(originalImage);

var bradleyfilter = new BradleyLocalThresholding();
bradleyfilter.ApplyInPlace(image);
Run Code Online (Sandbox Code Playgroud)

并将PointedColorFloodFill每个RGB分量的容差降低到例如10:

filter.Tolerance = Color.FromArgb(10, 10, 10);
Run Code Online (Sandbox Code Playgroud)

完全过滤的车牌现在看起来像这样:

在此输入图像描述