import cv2
import numpy as np
img_a=cv2.imread("d:/fangdong.jpg")
img_b=cv2.imread("d:/dog.jpg")
xishu=0.8
img_a=cv2.resize(img_a,(img_b.shape[1],img_b.shape[0]))
img_c=xishu*img_b+(1-xishu)*img_a
img_c=img_c.astype(np.uint8)
img_c=np.clip(img_c,0,255)
cv2.imshow('asdf', img_c)
cv2.waitKey(1)
import cv2
img_a=cv2.imread("d:/fangdong.jpg")
img_b=cv2.imread("d:/dog.jpg")
xishu=0.9
img_a=cv2.resize(img_a,(img_b.shape[1],img_b.shape[0]))
res=cv2.addWeighted(img_a,1-xishu,img_b,xishu,0)
cv2.imshow('asdf', res)
cv2.waitKey()
这个0.4,0.6就是img1,img2各自加的权重,0为偏值项
res=a1*x1+a2*x2+b
pil版:
https://blog.youkuaiyun.com/guduruyu/article/details/71439733/