def change_image_channels(image): # 3通道转单通道 if image.mode == 'RGB': r, g, b = image.split()#分离通道函数 return b import numpy as np from tqdm import tqdm import os import cv2 path=#图片路径 save_path=#图片保存路径 image = Image.open(path) image1=change_image_channels(image) image1=np.array(image1) cv2.imwrite(save_path,image1)