当前位置:网站首页>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()
边栏推荐
- 上位机开发C#语言:模拟STC串口助手接收单片机发送数据
- FPGA: Use of the development environment Vivado
- The query that the user's test score is greater than the average score of a single subject
- 如何测试一下现场的备机失败,转发主机的场景?
- Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
- 还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
- NowCoderTOP35-40 - continuous update ing
- Jenkins使用手册(2) —— 软件配置
- Getting started with Polkadot parachain development, this article is enough
- 第九章:activit内置用户组设计与组任务分配和IdentityService接口的使用
猜你喜欢
Our Web3 Entrepreneurship Project, Yellow
上位机开发C#语言:模拟STC串口助手接收单片机发送数据
Common operations of oracle under linux and daily accumulation of knowledge points (functions, timed tasks)
Complete image segmentation efficiently based on MindSpore and realize Dice!
产品太多了,如何实现一次登录多产品互通?
The founder of the DFINITY Foundation talks about the ups and downs of the bear market, and where should DeFi projects go?
IDEA performs the Test operation, resulting in duplicate data when data is inserted
【 temperature warning program DE development 】 event driven model instance
Egg framework usage (1)
【温度预警程序de开发】事件驱动模型实例运用
随机推荐
three objects are arranged in a spherical shape around the circumference
60行从零开始自己动手写FutureTask是什么体验?
2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)
教你本地编译运行一个IDEA插件,在IDEA里聊天、下棋、斗地主!
GCC编译的时候头文件搜索规则
IDEA performs the Test operation, resulting in duplicate data when data is inserted
RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)
Login function and logout function (St. Regis Takeaway)
Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
What are the standards for electrical engineering
2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
FPGA: Basic Getting Started LED Lights Blinking
RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
NowCoderTOP35-40——持续更新ing
用户考试分数大于单科科目平均分的查询
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
SkiaSharp 之 WPF 自绘 投篮小游戏(案例版)
第四章:activiti流程中,变量的传递和获取流程变量 ,设置和获取多个流程变量,设置和获取局部流程变量「建议收藏」
mysql索引