import numpy as np
from PIL import Image
#读入数据arr,此处为手动设置
arr = np.array(
[[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[1,1,1,1,1],[0,0,0,0,0]])
#将元素类型更改为
'uint8'
arr=np.array(arr,dtype=
'uint8')
arr=Image.fromarray(arr)
#第一个参数为存储的地址和名称,第二个参数为存储的图片类型
arr.save(
'test.bmp',
'bmp')
转载请注明原文地址: https://ju.6miu.com/read-39728.html