图片转numpy数组
基于PIL库
from PIL import Image
import numpy as np
img = Image.open('xxx.jpg')
img_array = np.array(img)
numpy数组转图片
基于PIL库
from PIL import Image
img = Image.fromarray(A) # A为一个numpy数组
img.save('xxx.jpg')
from PIL import Image
import numpy as np
img = Image.open('xxx.jpg')
img_array = np.array(img)
from PIL import Image
img = Image.fromarray(A) # A为一个numpy数组
img.save('xxx.jpg')