2

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

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

干杯

4

1 回答 1

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);

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

充满洪水的车牌

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

更新我偶然发现了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);

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

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

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

在此处输入图像描述

于 2012-08-03T13:23:07.800 回答