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()