【发布时间】:2020-01-07 17:03:22
【问题描述】:
我在 Tesseract OCR 中使用了下面的图片:
我处理图片的代码是:
# HOCR
with image[450:6200, 840:3550] as cropped:
imgPage = wi(image = cropped)
imageBlob = imgPage.make_blob('png')
horas = gerarHocr(imageBlob)
def gerarHocr(imageBlob):
image = Image.open(io.BytesIO(imageBlob))
markup = pytesseract.image_to_pdf_or_hocr(image, lang='por', extension='hocr', config='--psm 6')
soup = BeautifulSoup(markup, features='html.parser')
spans = soup.find_all('span', {'class' : 'ocrx_word'})
listHoras = []
...
return listHoras
虽然我的 OCR 有时会感到困惑,例如将 8 与 3 重复并返回 07:44/14:183 而不是 07:44/14:13。
我认为,如果我使用 Wand 删除灰线,我会提高 OCR 的信心。 请问我该怎么做?
谢谢,
【问题讨论】:
-
使用Image.level 方法。
-
也许将它作为 numpy 数组并使用类似
img[ img > 128 ] = 255的东西将一些灰色转换为白色
标签: python ocr tesseract python-tesseract wand