亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PyTesseract 在表中看不到一些個位數

PyTesseract 在表中看不到一些個位數

蕪湖不蕪 2023-06-20 16:01:56
我有這張桌子的圖片我正在嘗試使用 PyTesseract 解析它。我已經非常接近使用這段代碼了:from PIL import Image, ImageOpsimport pytesseractog_image = Image.open('og_image.png')grayscale = ImageOps.grayscale(og_image)inverted = ImageOps.invert(grayscale.convert('RGB'))print(pytesseract.image_to_string(inverted))這似乎非常準確,除了倒數第二列中的個位數是空白。我需要做一些不同的事情來獲取這些數字嗎?
查看完整描述

1 回答

?
富國滬深

TA貢獻1790條經驗 獲得超9個贊

Tesseract有多種頁面切分模式,選擇合適的切分模式有助于獲得最佳效果。

同樣在這種情況下,您可以限制tesseract為特定字符集。

另一件事tesseract是對字體和圖像大小敏感。一個簡單的調整大小可以大大改變結果。在這里,我將圖像大小水平更改為 2,垂直更改以獲得最佳結果;)

結合以上所有內容,您將獲得:

custom_config = r'--psm 6? -c tessedit_char_whitelist=0123456789.'

print(pytesseract.image_to_string(inverted.resize((1506, 412), Image.ANTIALIAS), config=custom_config))

? ? ??

1525 .199 303 82 161 162 7 .241

1464 .290 424 70 139 198 25 .352

1456 .292 425 116 224 224 0 .345

1433 .240 346 81 130 187 15 .275

1390 .273 373 108 217 216 3 .345

1386 .276 383 54 181 154 18 .315

1225 .208 255 68 148 129 1 .242

1218 .238 230 46 128 127 18 .273

1117 .240 268 43 113 1193 1 .308


查看完整回答
反對 回復 2023-06-20
  • 1 回答
  • 0 關注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號