我需要使用神经网络创建一个OCR系统来训练并从图像中读取字符…我是机器学习的新手,所以希望有人能指导我如何从图像中读取字符并与numpy数组进行比较
回答:
了解如何处理图像是一个很好的起点。你需要找出如何从图像转换为可以输入算法的矩阵。
这可以通过使用pillow、matplotlib等工具来完成 – https://pillow.readthedocs.io/en/stable/reference/Image.html – https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imread.html
以下是使用Pillow和numpy的示例代码:
from numpy import asarrayfrom PIL import Imageimage = Image.open('digits.jpeg')data = asarray(image)
你可能需要先将图像转换为灰度,或者根据你想要的结果以其他方式处理图像。