赞
踩
分割中将mask与原图叠加,生成漂亮的掩膜。
import os from PIL import Image root_path_background = "/home/cc/codes/python/YOLOP-main/datas/images/train/" root_path_paste = "/home/cc/codes/python/YOLOP-main/datas/da_seg_annotations/train/" output_path = "/home/cc/codes/python/YOLOP-main/datas/masks/" img_list = os.listdir(root_path_background) label_list = os.listdir(root_path_paste) img_list = sorted(img_list) label_list = sorted(label_list) for num,img_label in enumerate(zip(img_list,label_list)): img = Image.open(os.path.join(root_path_background,img_label[0])) label = Image.open(os.path.join(root_path_paste,img_label[1])) label = label.convert("RGB") fin = Image.blend(img,label,0.3) # fin.show() fin.save(os.path.join(output_path,img_label[0]))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。