np_array和Image的相互转换。

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import tensorflow as tf
sess=tf.Session()
img=Image.open(r"C:\Users\zy\Desktop\2007_000032.jpg")
#img=np.array(img)
img_1=np.array(img)
print(img_1.shape)

img_2=Image.fromarray(img_1)
plt.imshow(img_2)
plt.show()

猜你喜欢

转载自blog.csdn.net/weixin_41950276/article/details/84846348