当前位置:网站首页>Opencv learning notes - regions of interest (ROI) and image blending
Opencv learning notes - regions of interest (ROI) and image blending
2022-06-24 12:05:00 【cc_ rong】
Catalog
Region of interest (ROI)
Select an area in the image .
Definition ROI Area There are two forms of methods :
Method 1 :
Use Rect, Specify the coordinates of the upper left corner and the length and width of the rectangle
Mat roi = image(Rect(100, 100, 250, 250));image Is the loaded image .
Method 2 :
Specify the... Of the region of interest Range of rows and columns
Mat roi = image(Range(20, 150), Range(30, 300));Range: From the actual index to the end of the index A continuous sequence
According to the effect :
Code :
#include <iostream> #include "opencv2/opencv.hpp" using namespace cv; int main() { cv::Mat image = imread("E:\\roi_test.png"); cv::imshow(" Source graph ", image); cv::Mat roi = image(Range(30, 280), Range(60, 300)); cv::imshow("roi", roi); cv::waitKey(0); return 0; }
Image blending
First specify ROI, In use addweighted For the specified ROI The image of the region is mixed .
Linear blending is a typical binary pixel operation , The theoretical formula is :
g(x) = (1 - a)F1(x) + aF2(x)
a representative alpha Value (0.0~1.0), For two images (F1(x) and F2(x)) Or two videos (F1(x) and F2(x)) To produce the effect of overlapping pictures in time , A superimposed effect of switching from the front page to the back page .
Realization way :addWeighted function : Calculate two arrays ( Image array ) Weighted sum of
void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int dtype = -1);Parameters 1,InputArray Type of src1, Represents the first array to be weighted ;
Parameters 2,double Type of alpha, Express src1 The weight of ;
Parameters 3,InputArray Type of src2, Represents the second array , It needs and src1 Have Same size and number of channels ;
Parameters 4,double Type of beta, Express src2 The weight value of ;
Parameters 5,double Type of gamma, A scalar value added to the sum of the weights .
Parameters 6,OutputArray Type of dst, Output array , It has the same size and channel as the two input arrays Count ;
Parameters 7,int Type of dtype, Optional depth of output array , Have default values -1. When two input arrays have the same depth When the degree of , This parameter is set to -1( The default value is ), That is equivalent to src1.depth().
Two arrays (src1 and src2 ) Weighted sum of : Yes addWeighted Parameters in beta Position as 1 - alpha
gamma Position as 0
dst = src1[ i ] * alpha + src2[ i ] * beta + gamma;
i: Index values of multidimensional array elements , In the case of multi-channel arrays , Each channel needs to be handled independently . When the depth of the input array is CV_32S when , This function does not apply .
According to the effect :
Code :
Mat srcImg1; Mat srcImg2; Mat srcImg3; srcImg1 = imread("E:\\img\\logo3.png"); srcImg2 = imread("E:\\img\\logo4.png"); imshow(" Source graph srcImg1", srcImg1); imshow(" Source graph srcImg2", srcImg2); addWeighted(srcImg1, 0.5, srcImg2, 0.5, 0.0, srcImg3); imshow(" Mixed srcImg3", srcImg3);You can also specify roi after , Then mix a certain area in the picture .
边栏推荐
- Based on am335x development board arm cortex-a8 -- acontis EtherCAT master station development case
- 我在深圳,到哪里开户比较好?现在网上开户安全么?
- Jenkins performance test
- 如何开发短信通知和语音功能医院信息系统(HIS系统)
- Audio knowledge (III) -- MFCCs code implementation
- Insurance app aging service evaluation analysis 2022 issue 06
- GTEST from getting started to getting started
- 2022年有什么低门槛的理财产品?钱不多
- FreeRTOS概述与体验
- 《opencv学习笔记》-- 离散傅里叶变换
猜你喜欢

Basic path test of software test on the function of the previous day

电商红包雨是如何实现的?拿去面试用(典型高并发)

《opencv学习笔记》-- 图像的载入和保存

《opencv学习笔记》-- 离散傅里叶变换

Tools and methods - use code formatting tools in source insight

保险APP适老化服务评测分析2022第06期

ArrayList # sublist these four holes, you get caught accidentally
![[live review] battle code pioneer phase 7: how third-party application developers contribute to open source](/img/fa/e52bd8a1a404a759ef6ba88e8da0f0.png)
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source

Group planning - General Review

链接器 --- Linker
随机推荐
夜晚读书 -- 关于微服务和容器
New progress in the construction of meituan's Flink based real-time data warehouse platform
GTEST from getting started to getting started
单基因泛癌+简单实验就能发表7分+
It's so difficult for me. Have you met these interview questions?
Opencv optical flow prediction and remap remapping function usage
Ten thousand campus developers play AI in a fancy way. It's enough to see this picture!
2021-06-03: Boolean operation. Given a Boolean expression and an expected cloth
08. Tencent cloud IOT device side learning - device shadow and attributes
qt -- QTabWidget 中支持拖拽TabBar项
Why choose b+ tree as storage engine index structure
How can I open an account with new bonds? Is it safe
【Go语言刷题篇】Go从0到入门4:切片的高级用法、初级复习与Map入门学习
Google Earth Engine(GEE)—如何新增一个图例在Map面板
The latest hot spot: the use of copper death related genes for tumor prognosis typing!
Adobe Photoshop using the box selection tool for selection tutorial
程序员大部分时间不是写代码,而是。。。
Jenkins performance test
How to export only the titles in word documents? (i.e. delete all the text contents and keep only the title) stop B
u盘安装kali并且持久化



