【问题标题】:Cleaning Image for Reading Numbers Pytesseract用于读取数字的清洁图像 Pytesseract
【发布时间】:2019-08-12 22:23:33
【问题描述】:

我正在尝试从填充了名称和数字列的数据表中读取一些条目。这是原图:

在二值化、转换为黑/白和反转之间,我发现反转图像可以获得最佳结果。

 image = PIL.ImageOps.invert(image

当我向下滚动到更多图像时,这让我可以处理大约 90% 以上的列,但我仍然无法处理其中的一堆。有时,列中的括号合并了我在每列中的两个数字。有什么办法可以解决括号与数字混合的问题,或者删除所有绿色文本?

【问题讨论】:

    标签: python python-imaging-library python-tesseract image-preprocessing


    【解决方案1】:

    调整图像大小似乎是解决问题的选项。

    image = pyautogui.screenshot(region=(550, 354, 964, 552))
    width, height = image.size
    image = image.resize((args.resize*width, args.resize*height))
    

    我将大小调整为至少是原始大小的 3 倍。我想这增加了字符之间的距离,从而更容易识别一位数字的结尾和后面的括号。

    或者,以下是更大的改进:

    image = cv2.imread(output)
    image = cv2.bitwise_not(image)
    image = cv2.resize(image, None, fx=1.5, fy=1.7,
                                   interpolation=cv2.INTER_CUBIC)  # scale
    cv2.imwrite(output, image
    

    缩放不是线性的,如果稍微倾斜一下效果会更好。

    【讨论】:

      猜你喜欢
      • 2020-10-28
      • 1970-01-01
      • 2023-02-07
      • 2020-11-15
      • 1970-01-01
      • 2020-11-07
      • 1970-01-01
      • 2020-04-01
      • 1970-01-01
      相关资源
      最近更新 更多