0

有谁知道从图像中提取字符的好算法。所有字符都是黑色的,背景是白色的。事实上,这些图像将只是一个打印文档。我正在考虑使用诸如 DFS 或 BFS 之类的搜索算法来对字符进行聚类,但我不确定是否有更好的方法?你能推荐一些可以解决问题的库吗?我只想将图像切割成更小的图像,每个图像代表一个角色。

4

3 回答 3

2

Such algorithms are usually called OCR ( Optical Character Recognition ), under every operating system you may find ready to use utilities which do it better or worse, free, commercial, many of them. Actually, some are used e.g. with spam detection, for recognizing words on images in incoming email on-the-fly, so you can even do it from within shell, without even seeing images - more less successfully extract text from images to plain text files.

于 2012-09-22T19:07:10.740 回答
1

在 python through scipypackage 中,您可以使用该scipy.ndimage.label(img)方法。它应该标记图像中的不同字符,然后使用scipy.ndimage.find_objects提取这些字符。但是您需要先反转图像,使背景颜色为黑色而不是白色。

您可能想要发布图像以准确查看您想要的内容。

于 2012-10-09T20:47:41.757 回答
0

好的,这可能会有所帮助,但最后我使用 DFS 搜索了字符。我也有一些启发式方法来确定某个像素是否是角色的一部分。另外,由于有些字符是分开的(比如 i),后来我不得不决定是否将它们组合起来。事实上它工作得很好。它是很久以前完成的,但决定回答我很久以前提出的问题。

于 2014-11-01T13:38:35.627 回答