zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python 实现图片融合

Python 实现 图片 融合
2023-09-27 14:29:08 时间

python 实现图片融合

import cv2
import numpy as np

# Read image
img = cv2.imread("../paojie.jpg").astype(np.float32)
H, W, C = img.shape

img2 = cv2.imread("../bird.png").astype(np.float32)
img = cv2.resize(img,img2.shape[:2])

# 设置权重
a = 0.6
out = img * a + img2 * (1 - a)
out = out.astype(np.uint8)
    
# Save result
cv2.imwrite("out.jpg", out)
cv2.imshow("result", out)
cv2.waitKey(0)
cv2.destroyAllWindows()