或使用PIL/Pi对两幅黑白图像进行运算

2024-09-27 21:31:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用PIL/枕头对两个图像执行OR操作。目前我正在做这样的事情:

def image_union(figure1, figure2):

    image1 = Image.open(figure1.visualFilename)
    image2 = Image.open(figure2.visualFilename)

    blended = Image.blend(image1, image2, .5)
    output = ImageOps.grayscale(blended)
    output.save('out-' + figure1.name + '-' + figure2.name + '.png')

    return blended

我想要这两张照片:

enter image description here

enter image description here

但是上面的操作会返回以下结果,而我希望附着在恒星上的两个底部圆是完全黑色的:

enter image description here


Tags: orname图像imageoutputpilopen事情

热门问题