以及代码:
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)
不错,但打印结果是,2 WW
不是正确的文本2HHH
,那么如何删除这些黑点?
要直接从web提取文本,可以尝试以下实现
(making use of the first image)
:我对我们的社区有不同的女巫治疗方法。 这是我的方法
以下是我的解决方案:
相关问题 更多 >
编程相关推荐