【问题标题】:PIL preprocessing for tesseract ocrtesseract ocr 的 PIL 预处理
【发布时间】:2017-10-22 19:54:25
【问题描述】:

如何提高 OCR 的准确性?

我正在使用 pyocr 调用 tesseract 二进制文件wand 将 pdf 转换为 Image,然后 Pillow 为 OCR 处理图像。

已附上所有图片

我觉得这是可以做到的最好的预处理。

imgf = img.convert('RGB') #to draw a line in between
draw = Draw(imgf)
x,y = imgf.size
eX,eY = 20,800
box =  (x/2 - eX/2, y/2 - eY/2, x/2 + eX/2, y/2 + eY/2)
draw.ellipse(box, fill=0)
del draw


im2 = imgf.filter(ImageFilter.MinFilter(1))  #filter
im2 = im2.filter(ImageFilter.SMOOTH_MORE)
im2 = im2.filter(ImageFilter.SMOOTH_MORE)

for img in req_image:   # OCR
    txt = tool.image_to_string(
        im2,
        lang=lang,
        builder=pyocr.builders.DigitBuilder()
    )
print text

Image最初是从PDf中裁剪出来的,然后转换成灰度,然后上面的代码进行处理。

我在两者之间添加了一条线,发现它大大提高了准确性(感觉它会起作用)

1 Accurate 2 Accurate 3 Inaccurate Returns 6563 8 1 4 Greyscale image from pdf

【问题讨论】:

    标签: python ocr tesseract pillow image-preprocessing


    【解决方案1】:

    微软发布了一个很棒的 api,叫做认知服务。您可以使用它来进行图像识别。

    https://azure.microsoft.com/en-us/services/cognitive-services/

    【讨论】:

    • 是的,但我认为培训是个好主意。因为我有 1000 多个 PDF 到 OCR,仅用于数字和相同的字体。
    猜你喜欢
    • 2019-01-12
    • 2014-03-30
    • 2019-10-16
    • 2015-06-14
    • 1970-01-01
    • 2017-07-17
    • 2017-09-21
    • 2015-04-04
    • 2015-05-10
    相关资源
    最近更新 更多