opencv检测图片重复区域_用opencv实现图片部分区域透明覆盖

本文介绍如何利用OpenCV实现图片的区域透明覆盖,这一技术常见于移动应用中。通过cv2.addWeighted函数调整权重,可以创建不同透明度的效果。
摘要由CSDN通过智能技术生成

d86646c46e232de336f9aeec590cad4a.png

今天我们将使用opencv实现封面图所示的区域透明覆盖,这种透明覆盖在移动app上经常使用。代码如下:

# USAGE
# python overlay.py

# import the necessary packages
from __future__ import print_function
import numpy as np
import cv2

# load the image
image = cv2.imread("kobe.jpg")

# loop over the alpha transparency values
for alpha in np.arange(0, 1.1, 0.1)[::-1]:
	# create two copies of the original image -- one for
	# the overlay and one for the final output image
	overlay = image.copy()
	output = image.copy()

	# draw a green rectangle surrounding kobe'hand in the image
	# along with the text "PyImageSearch" at the top-left
	# corner
	cv2.rectangle(overlay, (150, 22), (260, 150),
		(0, 0, 255), -1)
	cv2.putText(overlay, "alpha={}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值