从车辆图像中提取车牌

时间:2012-08-03 11:35:40

标签: c# image-processing aforge anpr

我正在开发一个anpr应用程序,我已设法从车辆图像中找到车牌区域。 Following is the numberplate image i h ave extracted

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

干杯

1 个答案:

答案 0 :(得分: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);

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

Flood-filled number plate

你可能想尝试更浅灰色的填充颜色和不同的容差,但这个例子至少可以提供一个合理的起点。

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

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

var bradleyfilter = new BradleyLocalThresholding();
bradleyfilter.ApplyInPlace(image);

并将PointedColorFloodFill容差降低到例如每个RGB组件10个:

filter.Tolerance = Color.FromArgb(10, 10, 10);

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

enter image description here