久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 pytesseract OCR 識別圖像中的文本

Use pytesseract OCR to recognize text from an image(使用 pytesseract OCR 識別圖像中的文本)
本文介紹了使用 pytesseract OCR 識別圖像中的文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要使用 Pytesseract 從這張圖片中提取文字:

I need to use Pytesseract to extract text from this picture:

和代碼:

from PIL import Image, ImageEnhance, ImageFilter
import pytesseract
path = 'pic.gif'
img = Image.open(path)
img = img.convert('RGBA')
pix = img.load()
for y in range(img.size[1]):
    for x in range(img.size[0]):
        if pix[x, y][0] < 102 or pix[x, y][1] < 102 or pix[x, y][2] < 102:
            pix[x, y] = (0, 0, 0, 255)
        else:
            pix[x, y] = (255, 255, 255, 255)
img.save('temp.jpg')
text = pytesseract.image_to_string(Image.open('temp.jpg'))
# os.remove('temp.jpg')
print(text)

和temp.jpg"是

and the "temp.jpg" is

還不錯,但是打印的結果是,2 WW不是正確的文本2HHH,那我怎樣才能去除那些黑點呢?

Not bad, but the result of print is ,2 WW Not the right text2HHH, so how can I remove those black dots?

推薦答案

這是我的解決方案:

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter

im = Image.open("temp.jpg") # the second one 
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('temp2.jpg')
text = pytesseract.image_to_string(Image.open('temp2.jpg'))
print(text)

這篇關于使用 pytesseract OCR 識別圖像中的文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 人人色视频 | 久久婷婷香蕉热狠狠综合 | 男女啪啪网址 | 欧美国产日韩在线 | 国产精品高清一区二区三区 | 国产精品区二区三区日本 | 日韩欧美一级精品久久 | 日本一区二区在线视频 | 成人免费看| 小川阿佐美pgd-606在线 | 欧美色性 | 亚洲欧美综合精品久久成人 | 久久中文免费视频 | 一区二区三区四区视频 | 红桃视频一区二区三区免费 | 91久久看片 | 在线视频一区二区三区 | 欧美精品一区三区 | www久| www国产亚洲精品久久网站 | 美女天堂在线 | 久久精品亚洲国产奇米99 | 欧美日韩亚洲一区 | jlzzjlzz欧美大全 | 欧美日韩国产一区二区三区 | 成人水多啪啪片 | 九色在线观看 | 日韩精品在线一区 | 中文字幕在线观看第一页 | 在线国产一区二区 | 天天综合久久 | 欧美久久精品一级黑人c片 91免费在线视频 | 日韩一区和二区 | 丝袜 亚洲 另类 欧美 综合 | 欧美日韩在线不卡 | 波多野结衣一区二区 | 久久网站免费视频 | 日韩欧美国产一区二区 | 日韩激情在线 | 免费黄色录像视频 | 精品在线观看入口 |