笔记三:灰度(位深度8)转RGB(位深度24),支持批量

import os
from PIL import Image
from tqdm import tqdm
 
img_path = 'D:/dataset/5/Sea'  # 填入图片所在文件夹的路径
img_Topath = 'D:/dataset/6/Sea'  # 填入图片转换后的文件夹路径
 
for item in tqdm(os.listdir(img_path)):
    arr = item.strip().split('*')
    img_name = arr[0]
    image_path = os.path.join(img_path, img_name)
    img = Image.open(image_path)
    if (img.mode != 'RGB'):
        img = img.convert("RGB")
        img.save(img_Topath +'/'+img_name)

仅个人笔记,原作者在这

你可能感兴趣的:(python,开发语言)