矩阵与图片转化

from PIL import Image
import numpy as np
def loadImage():
    # 读取图片
    im = Image.open("E://moe//datasets3//bad//0- (9).jpg")

    # 显示图片
    im.show()

    im = im.convert("L")
    data = im.getdata()
    data = np.matrix(data)
    #     print data
    # 变换成30.30
    data = np.reshape(data, (30, 30))
    new_im = Image.fromarray(data)
    # 显示图片
    new_im.show()
loadImage()
发布了6 篇原创文章 · 获赞 4 · 访问量 88

猜你喜欢

转载自blog.csdn.net/Fighting_y/article/details/104900260