简体   繁体   English

准备用于OCR的图像

[英]Prepare Image for OCR

The images that I have gives me inconsistent results. 我的图像给我不一致的结果。 My thought process is: my text is always in white font; 我的思考过程是:我的文本始终为白色字体; if I can switch the pixel of my text to black and turned everything else to white or transparent, I will have better success. 如果我可以将文本的像素切换为黑色,并将其他所有像素切换为白色或透明,我将获得更好的成功。

My question is, what library or language is best for this? 我的问题是,哪种图书馆或语言最适合? Do I have to turn my white pixel into some unique RGB, turn everything else to white or transparent, then find the unique RGB and make that black? 我是否必须将我的白色像素变成一些独特的RGB,将其他所有颜色都变成白色或透明,然后找到独特的RGB并将其变成黑色? Any help is appreciated. 任何帮助表示赞赏。

Yes, if you could make the text pixels black and all the rest of the documents white you would have better success, although this is not always possible, there are processes that can help. 是的,如果您可以将文本像素设置为黑色,而将所有其他文档设置为白色,则可能会获得更好的成功,尽管并非总是可能的,但有些过程可以提供帮助。

  • The median filter (and other low pass filters) can be used to remove noise present in the image. 中值滤波器(和其他低通滤波器)可用于消除图像中存在的噪声。

  • erosion can also help to remove things that are not characters, like thin lines and also noise. 侵蚀还可以帮助去除不是字符的东西,例如细线和噪音。

  • align the text is also a good idea, the OCR accuracy can drop considerably if the text is not aligned. 对齐文本也是一个好主意,如果文本未对齐,OCR准确性可能会大大下降。 To do this you could try the Hough transform followed by a rotation. 为此,您可以尝试Hough变换,然后进行旋转。 Use the Hough transform to find a line in your text and then rotate the image in the same angle as the line. 使用霍夫变换在文本中找到一条线,然后以与该线相同的角度旋转图像。

All processing steps mentioned can be done with opencv or scikit-image. 提到的所有处理步骤都可以使用opencv或scikit-image完成。

Is also good to point out that there are many other ways to process text, too many to mention. 还要指出的是,还有许多其他方式可以处理文本,因此有太多的提及。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM