当前位置:网站首页>Opencv算术操作
Opencv算术操作
2022-08-05 10:23:00 【The code family】
- 图像加法
你可以使用opencv的cv.add()函数把两幅图像相加,或者可以简单的通过numpy操作添加两个图像,如res=img1+img2。两个图像应该具有相同的大小和类型,或者第二个图像可以是标量值。
注意:opencv加法和numpy加法之间存在差异。opencv的加法是饱和操作,而numpy添加是模运算。
参考代码:
>>> x =np.uint8([250])
>>> y =np.uint8([10])
>>> print (cv.add(x,y)) # 250+10=260=>255
[[255]]
>>> print(x+y) #250+10=260%256=4
[4]
- 图像的混合
这其实也是加法,但是不同的是两幅画的权重不同,这就会给人一种混合或者透明的感觉。图像混合的计算公式:
参考代码:
Import numpy as np
Import cv2 as cv
Import matpiotlib.pyplot as plt
#读取图像
Img1 = cv.imread(“ ”)
Img2 = cv.imread(“ ”)
#图像混合
Img3 = cv.addWeighted(img1,0.7,img2,0.3,0)
#图像显示
Plt.figure(figsize=(8,8))
Plt.imshow(img3[:,:,::-1])
Plt.show()
边栏推荐
- three.js调试工具dat.gui使用
- 阿里全新推出:微服务突击手册,把所有操作都写出来了PDF
- The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!
- Data Middle Office Construction (10): Data Security Management
- 企业的数字化转型到底是否可以买来?
- 华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)
- 012_SSS_ Improving Diffusion Model Efficiency Through Patching
- Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
- FPGA: Basic Getting Started LED Lights Blinking
- 2022杭电多校 第6场 1008.Shinobu Loves Segment Tree 规律题
猜你喜欢
产品太多了,如何实现一次登录多产品互通?
linux下oracle常见操作以及日常积累知识点(函数、定时任务)
MySQL事务
High-quality DeFi application building guide to help developers enjoy DeFi Summer
5. Deploy the web project to the cloud server
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
Create a Dapp, why choose Polkadot?
RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
Pycharm 常用外部工具
Data Middle Office Construction (10): Data Security Management
随机推荐
公众号如何运维?公众号运维专业团队
创建一个 Dapp,为什么要选择波卡?
FPGA: Basic Getting Started LED Lights Blinking
PHP operation mangoDb
上位机开发C#语言:模拟STC串口助手接收单片机发送数据
2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
uniapp connect ibeacon
什么是 DevOps?看这一篇就够了!
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
5. Deploy the web project to the cloud server
js hijacks the array push method
教你本地编译运行一个IDEA插件,在IDEA里聊天、下棋、斗地主!
Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
Egg framework usage (2)
Brief Analysis of WSGI Protocol
three物体围绕一周呈球形排列
What is SPL?
Development common manual link sharing
[Android]如何使用RecycleView in Kotlin project
Login function and logout function (St. Regis Takeaway)