当前位置:网站首页>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()
边栏推荐
- 我们的Web3创业项目,黄了
- Jenkins manual (2) - software configuration
- Egg framework usage (1)
- 产品太多了,如何实现一次登录多产品互通?
- 第六章:activiti流程分流判断之排它网关和并行网关
- Why are RELTABLESPACE values 0 for many tables displayed in sys_class?
- The host computer develops C# language: simulates the STC serial port assistant to receive the data sent by the microcontroller
- 第五章:redis持久化,包括rdb和aof两种方式[通俗易懂]
- GCC编译的时候头文件搜索规则
- This notebook of concurrent programming knowledge points strongly recommended by Ali will be a breakthrough for you to get an offer from a big factory
猜你喜欢

JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number

NowCoderTOP35-40 - continuous update ing

教你本地编译运行一个IDEA插件,在IDEA里聊天、下棋、斗地主!

Getting started with Polkadot parachain development, this article is enough

Technical dry goods | Hausdorff distance for image segmentation based on MindSpore

STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)

Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)

This notebook of concurrent programming knowledge points strongly recommended by Ali will be a breakthrough for you to get an offer from a big factory

华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)

上位机开发C#语言:模拟STC串口助手接收单片机发送数据
随机推荐
PCB布局必知必会:教你正确地布设运算放大器的电路板
2022杭电多校 第6场 1008.Shinobu Loves Segment Tree 规律题
攻防世界-PWN-new_easypwn
Egg framework usage (1)
皕杰报表的下拉框联动
Jenkins manual (2) - software configuration
力扣(LeetCode)216. 组合总和 III(2022.08.04)
气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)
Egg framework usage (2)
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
[Unity] [UGUI] [Display text on the screen]
Oracle 19.3 restart 环境
SD NAND Flash简介!
19. Server-side session technology Session
这份阿里强推的并发编程知识点笔记,将是你拿大厂offer的突破口
Can MySQL use aggregate functions without GROUP BY?
PCB layout must know: teach you to correctly lay out the circuit board of the op amp
Score interview (1)----related to business
使用工具类把对象中的null值转换为空字符串(集合也可以使用)
How to choose coins and determine the corresponding strategy research