MASK图(单色通道,需要转成RGB模式)只保留白色部分,把黑色转为透明色,再叠加到另一张图片上
最终效果:
from PIL import Image
# open images
painting = Image.open("XXX\\000656.jpg")
mask = Image.open("XXX\celeba_01.png")
mask = mask.convert("RGB")
def pixel_filter(image, condition, true_colour, false_colour):
filtered = Image.new("RGBA", image.size)
pixels = list(image.getdata())
for index, colour in enumerate(pixels):
print(colour)
if colour == condition: