Opencv随笔3------图片的融合(挺有意思的)

 效果图如下:

 原图片:

直接放代码

import cv2
import os
path1 = os.path.join(os.getcwd(), 'pic/8.jpg')
path2 = os.path.join(os.getcwd(), 'pic/9.jpg')
img1 = cv2.imread(path1, 1)
img2 = cv2.imread(path2, 1)
shape = img2.shape
height = shape[0]
width = shape[1]
img3 = cv2.resize(img1, (width, height))#把图片变成一样大小,assWeighted 要求一样大小
print img3.shape
# roiH = int(height /2)
# RoiW = int(width /2)
# img1ROI = img1[0:roiH, 0: RoiW]
# img2ROI = img2[0:roiH, 0: RoiW]

# dst = np.zeros((roiH, RoiW, 3), np.uint8)
dst = cv2.addWeighted(img3, 0.5, img2, 0.5 ,0)#融合函数
# cv2.imwrite('pic/wacuan.jpg',dst)
cv2.imshow("dst" ,dst)
cv2.waitKey(0)

猜你喜欢

转载自blog.csdn.net/qq_42105426/article/details/89473912