图片融合

原理:图像1某部分和图像2某部分(大小一样)分别乘以一个系数(这两个系数和为一)

p1*0.3 + p2*0.7

import cv2
import numpy as np
img0 = cv2.imread('D:/pythonob/imageinpaint/img/zidan.jpg',1)
img1 = cv2.imread('D:/pythonob/imageinpaint/img/demo.jpg',1)
imgInfo = img0.shape
height = imgInfo[0]
width = imgInfo[1]
roiHeight = int(height/2)
roiWidth = int(width/2)
img0Roi = img0[0:roiHeight,0:roiWidth]
img1Roi = img1[0:roiHeight,0:roiWidth]
dst1 = np.zeros((roiHeight,roiWidth,3),np.uint8)#API实现
dst1 = cv2.addWeighted(img0Roi,0.5,img1Roi,0.5,0)
cv2.imshow('API',dst1)
cv2.waitKey(0)

效果图:

猜你喜欢

转载自www.cnblogs.com/cxxBoo/p/11454534.html