灰度图像img.shape、(height, width)转为(height, width, channels)
from PIL import Imageimport numpy as npimport matplotlib.pyplot as pltimport cv2img = ‘./control23.tif’img = Image.open(img)img = np.array(img)print(img.shape)img=np.stack((img,)*3,axis=-1)print(img.shape)plt.imshow(img)