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

# coding=gbk from PIL import Image import numpy as np # import scipydef loadImage(): # 读取图片 im = Image.open("lena.jpg")# 显示图片 im.show() im = im.convert("L") data = https://www.it610.com/article/im.getdata() data = np.matrix(data) #print data # 变换成512*512 data = np.reshape(data,(512,512)) new_im = Image.fromarray(data) # 显示图片 new_im.show()loadImage()


    推荐阅读