gpt4 book ai didi

OpenCV 颜色浓度直方图

转载 作者:太空宇宙 更新时间:2023-11-03 20:42:16 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com