OpenCV 颜色浓度直方图

标签 opencv computer-vision ocr automatic-license-plate-recognition

我正在使用 OpenCV 开发 ANPR 系统,并在几篇文章中看到了一种进行字符分割的方法。这个想法是制作一个图表来显示整个图像的颜色浓度。

我该怎么做?

enter image description here

这是我的图片:

enter image description here

我需要检测如上所示的黑色区域的位置以识别每个字符。

我曾尝试逐个像素地添加值,但我是在 Android 上这样做的,这花费的时间是 Not Acceptable 。

最佳答案

好的,一个月后,但我为此给你写了一些代码(在 python 中);)

(假设你只是在图像密度直方图之后)

import cv

im2 = cv.LoadImage('ph05l.jpg')
width, height = cv.GetSize(im2)
hist = []
column_width = 1   # this allows you to speed up the result,
                   # at the expense of horizontal resolution. (higher is faster)
for x in xrange(width / column_width):
    column = cv.GetSubRect(im2, (x * column_width, 0, column_width, height))
    hist.append(sum(cv.Sum(column)) / 3)

为了加快速度,您不需要更改图像文件,只需更改采样的 bin 宽度(脚本中的 column_width),显然,如果您这样做会损失一些分辨率(如您可以在下图中看到)。

在图像中,我使用您的文件显示结果(绘制 hist),使用 column_width 的 1、10 和 100。它们以 0.11 运行, 0.02 和 0.01 秒。

我写在了PIL也一样,但它的运行速度要慢大约 5 到 10 倍。

character density histograms

关于OpenCV 颜色浓度直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9351278/

相关文章:

python - 如何将矩形蒙版放在矩形对象上

c++ - OPENCV:查找线的方向/角度

python - 使用 K 均值聚类 OpenCV 进行交通标志分割

linux - pdf 到文本的转换不准确

android - 扫描图像并检测文本android

python - opencv人脸识别: subspaceproject and subspacereconstruct methods in python

matlab - 如何在 MATLAB 中获取像素邻居?

python - Python Bot 的基本计算机视觉技术。

android - 在Android中集成Tesseract OCR引擎

java - android opencv Utils.BitmapToMap 运行时异常帮助?