import cv2
import numpy as np
# 图像混合
img1 = cv2.imread('add1.png')# (380, 308, 3) #读取图片1
img2 = cv2.imread('add2.png')# (380, 308, 3) #读取图片2
dst = cv2.addWeighted(img1, 0.7, img2, 0.3, 0)
# 第一幅图的权重是 0.7 第二幅图的权重是 0.3。大概就是第二幅图浮现加在第一个图上
#g(x) = αf(x) + β,其中:α(>0)、β常称为增益与偏置值,分别控制图片的对比度和亮度。
res = np.uint8(np.clip((1.5 * dst + 10), 0, 255)) # 1.5是对比度 10是亮度
cv2.imwrite("res.png",res) #保存
cv2.imshow('dst', res) #显示
cv2.waitKey(0)
cv2.destroyAllWindows()