标签:http pre color lse point 转化 alt 识别 convert
#效果不是很好 加上灰度处理和二值化处理 就变好了 import pytesseract from PIL import Image from PIL import ImageEnhance #打开图片 img = Image.open(‘f7vf.png‘) #提高辨识度 img = img.convert(‘RGB‘) enhancer = ImageEnhance.Color(img) enhancer = enhancer.enhance(0) enhancer = ImageEnhance.Brightness(enhancer) enhancer = enhancer.enhance(2) enhancer = ImageEnhance.Contrast(enhancer) enhancer = enhancer.enhance(8) enhancer = ImageEnhance.Sharpness(enhancer) img = enhancer.enhance(20) #转化为灰度图片 img = img.convert(‘L‘) #img.show() # exit() #二值化处理 threshold = 140 table = [] for i in range(256): if i < threshold: table.append(0) else: table.append(1) out = img.point(table,‘1‘) # out.show() # exit() #识别图片 print(pytesseract.image_to_string(img))
标签:http pre color lse point 转化 alt 识别 convert
原文地址:https://www.cnblogs.com/Qiuzhiyu/p/12183163.html