【Python】PIL库中图像的mode参数_mjiansun的博客-CSDN博客
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
img_path = "d:/a/cat_1.jpg"
# 转换前
img = Image.open(img_path)
print("转换前\n shape: {}\n {}".format(img.size, img))
ar = np.array(img)
print(ar.shape)
print(img)
plt.imshow(ar)
plt.show()
# 转换后
img = img.convert('RGB')
print("转换后\n shape: {}\n {}".format(img.size,img))
ar = np.array(img)
print(ar.shape)
print(img)
plt.imshow(ar)
plt.show()