我正在尝试将两个图像叠加在一起,以模拟使用MatLab叠加的图像的结果。不幸的是,我不能在这个项目中使用MatLab,而且我使用混合的方法没有给出想要的结果。

关于如何使用Python完成图像的叠加,您有什么想法吗?
下面是我尝试使用混合方法的代码部分。但是,它会产生发光效果:
# Blend method from
# http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html
target = img_1 / 255.0
blend = img_2 / 255.0
output_img = (target > 0.5) * (1 - (1-2*(target-0.5)) * (1-blend)) + (target <= 0.5) * ((2*target) * blend)
output_img = output_img*255.0这里是我开始的两张图片:


发布于 2019-06-06 10:33:47
你可以用Pillow做到这一点:
from PIL import Image
im1 = Image.open("background.jpg")
im2 = Image.open("bird.jpg")
newimg = Image.blend(im1, im2, alpha=0.5)
newimg.save("blended.jpg")我得到的结果是:

https://stackoverflow.com/questions/56469966
复制相似问题