赞
踩
给定两张图像分别为
X
1
X_1
X1和
X
2
X_2
X2利用cv2进行图像融合生成
X
3
X_3
X3
X
3
=
α
⋅
X
1
+
(
1
−
α
)
⋅
X
2
X_3=\alpha\cdot X_1 + (1-\alpha)\cdot X_2
X3=α⋅X1+(1−α)⋅X2这两边张图片分别如下所示
import cv2
import numpy as np
alpha = 0.1 #0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9
filename = str(alpha)+r'.png'
img1 = cv2.imread('img/1.png')
img2 = cv2.imread('img/2.png')
img1_resize = cv2.resize(img1, (400 , 400))
img2_resize = cv2.resize(img2, (400 , 400))
img_merge = alpha * img1_resize + (1 - alpha) * img2_resize
cv2.imshow(filename, img_merge/255.0)
cv2.waitKey(0)
cv2.imwrite(filename, img_merge)
输出的结果如下所示:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。