利用alpha通道进行图像blend

光流中第一帧与第二帧进行叠加,直接上代码

# -*- coding:utf-8 -*-
from PIL import Image
def blend_two_images():
  img1 = Image.open( "bridge.png ")
  img1 = img1.convert('RGBA')
  img2 = Image.open( "birds.png ")
  img2 = img2.convert('RGBA')
  img = Image.blend(img1, img2, 0.3)
  img.show()
  img.save( "blend.png")
  return
blend_two_images()

两幅图像进行合并时,按公式:blended_img = img1 * (1 – alpha) + img2* alpha 进行。

猜你喜欢

转载自blog.csdn.net/Gussss/article/details/100865236