久久久久久久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

還不錯,但是打印的結(jié)果是,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)

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

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

相關(guā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?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 日日做夜夜爽毛片麻豆 | 欧美日韩不卡合集视频 | 中文字幕一区二区三区在线观看 | 国产精品久久 | 日日日日操 | 日韩精品极品视频在线观看免费 | 久久久久久久国产精品视频 | 欧美一区二区三区 | 精品一区二区在线观看 | 婷婷福利 | 久久国产精品视频 | 成人高清在线 | 国产精品视频免费播放 | 精品久久久久久久 | 亚洲成人av | 国产乱码精品一区二区三区中文 | 欧美日韩电影免费观看 | 久久人体 | 久久久久国产一级毛片高清网站 | 日韩一区二区av | 亚洲国产日韩欧美 | 91在线区| 干一干操一操 | 日本天天色 | 国产精品久久久亚洲 | 91色在线视频 | www.yw193.com | 在线视频91 | 国产亚洲精品久久久久动 | 国产91久久久久 | 国产高清一区二区三区 | 日本成人在线观看网站 | 午夜免费福利片 | 亚洲第一视频网站 | 亚洲欧美日韩在线一区二区 | 欧美黄色片 | 男女视频在线免费观看 | 国产高清视频 | 国产精品欧美一区二区三区 | 欧美不卡一区二区三区 | 亚洲国产一区二区三区在线观看 |