# -*- coding: utf-8 -*- """ Created on Fri Oct 7 12:29:59 2022 @author: shsbnu """ import cv2 import numpy as np imsrc1 = cv2.imread("pic/yyp2.jpg") b,g,r=cv2.split(imsrc1) alpha= np.ones(b.shape, dtype=b.dtype) * 255 imsrc1= cv2.merge((b, g, r, alpha)) cv2.imshow("1",imsrc1) imsrc2 = cv2.imread("pic/logo.png", cv2.IMREAD_UNCHANGED) imsrc2=cv2.resize(imsrc2,(100,100)) row,col,ch=imsrc2.shape alpha = imsrc2[:,:,3] / 255.0 src = 1 - alpha for i in range(3): imsrc1[:col,:row,i]=imsrc1[:col,:row,i]*src+alpha*imsrc2[:,:,i] cv2.imshow("merge", imsrc1) cv2.waitKey(0) cv2.destroyAllWindows()