将分割图和原图合在一起

# 将分割图和原图合在一起
from PIL import Image
import matplotlib.pyplot as plt
 
#image1 原图 
#image2 分割图
image1 = Image.open('/home/kesci/input/DRIVE4417/01_test.tif')
image2 = Image.open('/home/kesci/input/DRIVE4417/01_manual1.gif')
 
image1 = image1.convert('RGBA')
image2 = image2.convert('RGBA')
 
#两幅图像进行合并时,按公式:blended_img = img1 * (1 – alpha) + img2* alpha 进行
image = Image.blend(image1,image2,0.3)
image.save("test.png")
image.show()

 

原文地址:https://www.cnblogs.com/ylHe/p/13922144.html