# dst = src1*a+src2*(1-a)
import cv2
import numpy as np
img0 = cv2.imread('image0.jpg',1)
img1 = cv2.imread('image1.jpg',1)
imgInfo = img0.shape
height = imgInfo[0]
width = imgInfo[1]
# ROI 先获取感兴趣范围,相当于从原图片抠图一块,而这一块的宽高就是roiW,roiH
roiH = int(height/2)
roiW = int(width/2)
img0ROI = img0[0:roiH,0:roiW] #开始抠图
img1ROI = img1[0:roiH,0:roiW]
# dst 目标图片
dst = np.zeros((roiH,roiW,3),np.uint8) #初始化一张目标图片
dst = cv2.addWeighted(img0ROI,0.5,img1ROI,0.5,0)#add src1*a+src2*(1-a) 两张图片权重相加
# (src1 , a , src2 , 1-a)
cv2.imshow('dst',dst)
cv2.waitKey(0)
image.png
网友评论