目录

OpenCV-Python 图像混合(图像加权法)

这也是图像添加,但为图像赋予不同的权重,以产生混合或透明的感觉。

示例代码如下:

import cv2 as cv

# 读取图像文件
img1 = cv.imread('ml.png')
img2 = cv.imread('opencv-logo.png')

# 图像重叠
dst = cv.addWeighted(img1,0.3,img2,0.7,0)

# 显示图像
cv.imshow('dst',dst)
cv.waitKey(0)

# 退出程序,释放资源
cv.destroyAllWindows()

这里设置了第一张图片的权重为 0.3, 第二张图片为 0.7 所混合出来的效果。(注意是权重混合,并不是透明度设置,具体可参考官方文档:https://docs.opencv.org/4.5.5/d2/de8/group__core__array.html#gafafb2513349db3bcff51f54ee5592a19)

示例代码下载:


上一篇:«

下一篇: »


评论

  1. 这篇文章写得非常出色,作者在文字中展现了出色的驾驭能力和深厚的文学功底,行文流畅,确实写得非常好,让人由衷欣赏。https://edu.vso.com.cn/ 支持博主!这篇文章写得非常出色,作者在文字中展现了出色的驾驭能力和深厚的文学功底,行文流畅,确实写得非常好,让人由衷欣赏。https://edu.vso.com.cn/ 支持博主!


Warning: Undefined variable $req in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 232

Warning: Undefined variable $commenter in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 233

Warning: Trying to access array offset on value of type null in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 233

Warning: Undefined variable $aria_req in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 233

Warning: Undefined variable $req in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 236

Warning: Undefined variable $commenter in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 237

Warning: Trying to access array offset on value of type null in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 237

Warning: Undefined variable $aria_req in /www/wwwroot/wxzzz.com/wp-content/themes/quirk-wordpress-theme-master/functions.php on line 238

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注