python如何把像素图转换成文字

图片如下,是位图,有几万个,而且模糊不清,如何用python把下图转换成文字

本人已经安装了pytesseract,pillow等库

但识别率很低,特请教一下大神们!

1.先把原图进行一些预处理,比如你这个图片就是明显偏白了,可以做一次直方图均衡或者直接用二值化,使字体清晰时候在用pytesseract来识别,准确率会高很多。

2.不管是是用什么来识别,都不可能和人一样百分百可以识别到正确的结果,所以我的建议就是需要加上一个字典来辅助识别。对每个字符识别,返回概率最高的5个,然后根据字典来组成完整的字符串,正确率会高很多。

挺清楚的啊,调用个深度学习的图像文字识别啊

百度智能云的深度学习图像文字识别:https://cloud.baidu.com/product/ocr_general?track=cp:nsem|pf:pc|pp:nsem-chanpin-tongyongwenzishibie-124|pu:xsem-wenzishibie-tongyongci|ci:|kw:10119484&bd_vid=11134765955655670987

阿里云

腾讯云肯定都有相应的产品

Python图片转换成矩阵,矩阵数据转换成图片

 

# coding=gbk
from PIL import Image
import numpy as np
# import scipy
import matplotlib.pyplot as plt

def ImageToMatrix(filename):
    # 读取图片
    im = Image.open(filename)
    # 显示图片
# im.show() 
    width,height = im.size
    im = im.convert("L") 
    data = im.getdata()
    data = np.matrix(data,dtype=‘float‘)/255.0
    #new_data = np.reshape(data,(width,height))
    new_data = np.reshape(data,(height,width))
    return new_data
# new_im = Image.fromarray(new_data)
# # 显示图片
# new_im.show()
def MatrixToImage(data):
    data = data*255
    new_im = Image.fromarray(data.astype(np.uint8))
    return new_im



filename = ‘lena.jpg‘
data = ImageToMatrix(filename)
print data 
new_im = MatrixToImage(data)
plt.imshow(data, cmap=plt.cm.gray, interpolation=‘nearest‘)
new_im.show()
new_im.save(‘lena_1.bmp‘)