PIL is the most common image processing library in python, and format conversion between PIL and numpy arrays is often encountered in deep learning
PIL to numay conversion
from PIL import Image
img = Image.open("./hh.png")
img = np.array(img)
convert numay to PIL
from PIL import Image
import numpy as np
##生成一个随机数组
##randint()生成一定范围的数组
##random()生成0-1之间的均匀分布
##randn() 生成高斯分布
img=np.random.randint(0,255,(48,48))
img = Image.fromarray(img)
img.show()