最近用matplotlib遇到了一些坑,记录一下. 图片转数组 import matplotlib.pyplot as plt im_file='test_image.jpg' img=plt.imread(im_file) print(img.shape) print(img.dtype) # img: numpy array with shape (H,W,c) # uint8 如上,类型是uint8的. 数组转图片 分为以下情况:3通道和单通道,浮点数组和整形数组. 三通道,浮点数组 三通