当前位置:   article > 正文

mask与原图叠加_掩模图与原图叠加python

掩模图与原图叠加python

分割中将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]))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/929305
推荐阅读
相关标签
  

闽ICP备14008679号