主要介绍了python利用蒙版抠图(使用PIL.Image和cv2)输出透明背景图,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
1
因为最近在做深度学习抠图,正好要用到蒙版进行抠图,所以我将抠图代码进行了封装注释,可以直接使用。可能走了弯路,若有高见请一定提出! 主要代码 import cv2 from PIL import Image import numpy as np class UnsupportedFormat(Exception): def __init__(self, input_type): self.t = input_type def __str__(self): return "不支持'{}'模式的转换,请使用为图片地址(path)、PIL.Image(pil)或OpenCV(cv2)模
2021-10-25 11:26:55 390KB c python 背景图
1