zhiqingstudy

Be a young person with knowledge and content

import cv2
import numpy as np


# 导入图片
pic=cv2.imread('20220627220739.jpg')

# 创建logo和mask
logo=np.zeros((200,200,3),np.uint8)
mask=np.zeros((200,200),np.uint8)

# 绘制logo
logo[20:120,20:120]=[0,0,255]
logo[80:180,80:180]=[0,255,0]

mask[20:120,20:120]=255
mask[80:180,80:180]=255

# 对mask按位求反
m=cv2.bitwise_not(mask)

# 选择添加logo的位置
roi=pic[0:200,0:200]

# 与m进行位操作
tmp=cv2.bitwise_and(roi,roi,mask=m)

dst=cv2.add(tmp,logo)

pic[0:200,0:200]=dst

# 显示图片
cv2.imshow('pic',pic)
# cv2.imshow('logo',logo)
# cv2.imshow('mask',mask)
# cv2.imshow('tmp',tmp)
# cv2.imshow('dst',dst)
cv2.waitKey(0)
comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号