当前位置:网站首页>Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
2022-06-30 08:47:00 【Chasing foot dream】
OpenCV Learning notes
day5- Arithmetic operation of image pixels
function
‘+’ ‘-’ ‘*’ ‘/’
example 1
Mat dst;
dst = image + Scalar(50, 50, 50);
// to image Add... To each pixel 50
dst = image - Scalar(50, 50, 50);// reduce 50
dst = image / Scalar(2, 2, 2);// Divide 50
// Multiplication is usually done with functions
Function requires addition ( reduce , ride , except ) The two images of have the same size , And the pixel type is the same .
| Parameters | explain |
|---|---|
| src1 | The first input array |
| src2 | Second and src1 An input array of the same size and type . |
| dst | The size and type of the output array are the same as src2 identical |
| scale | Scalar factor |
| src2 | Second and src1 An input array of the same size and type . |
| dtype | The type of the output array is optional ; If -1,dst There will be depth src2.depth(), |
| But in the case of array partitioning , When src1.depth()==src2.depth() when , Can only be passed -1. |
1. multiply();// Multiplication function multiply( The first image , Second image , Output image )
CV_EXPORTS_W void multiply(InputArray src1, InputArray src2,OutputArray dst, double scale = 1, int dtype = -1);
2. add(image,m,dst);// Addition function
void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
4. subtract(image,m,dst);// Subtraction function
void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
5. divide(image, m, dst);// Division function
void divide(InputArray src1, InputArray src2, OutputArray dst,double scale=1, int dtype=-1);
Code
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
#include <iostream>
void QuickDemo::operators_demo(Mat &image)
{
Mat dst;
namedWindow(" Original picture ", WINDOW_NORMAL);
imshow(" Original picture ", image);// Show results 1
//dst = image + Scalar(50, 50, 50);// to image Add... To each pixel 50-- Show results 2
//dst = image - Scalar(50, 50, 50);// reduce 50-- Show results 3
//dst = image / Scalar(2, 2, 2);// Divide 50-- Show results 4
// Multiplication
Mat m = Mat::zeros(image.size(),image.type());
m=Scalar(2, 2, 2);
multiply(image,m,dst);// Multiplication function multiply( The first image , Second image , Output image )-- Show results 5
add(image,m,dst);// Addition function
subtract(image,m,dst);// Subtraction function
divide(image, m, dst);// Division function
namedWindow("... operation ", WINDOW_NORMAL);
imshow("... operation ", dst);
}//operators_demo
Show results 1
Show results 2
Show results 3
Show results 4
Show results 5
边栏推荐
- Understanding society at the age of 14 - reading notes on "happiness at work"
- Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
- El input limit can only input numbers
- Unity basic lighting model
- Dart tips
- Influencing factors of echo cancellation for smart speakers
- JVM tuning related commands and explanations
- Does the oscilloscope probe affect the measurement of capacitive load?
- CUDA implements matrix replication
- 示波器探头对测量电容负荷有影响吗?
猜你喜欢

维基媒体基金会公布新商业产品“维基媒体企业”首批客户

电流探头电路分析

【NVMe2.0b 14】NVMe Admin Command Set

Summary of common pytoch APIs

Bind threads to run on a specific CPU logical kernel

TiDB 6.0:让 TSO 更高效丨TiDB Book Rush

Flink 数据偶尔数据积压导致checkpoint失败

Detectron2 source code reading 3-- encapsulating dataset with mapper

Redis design and Implementation (V) | sentinel sentry

el-input 限制只能输数字
随机推荐
C # get the current timestamp
Unity basic lighting model
Redis design and Implementation (I) | data structure & object
Implementing custom drawer component in quick application
Summary of common pytoch APIs
[untitled]
Comparison of two ways for C to access SQL Server database (SqlDataReader vs SqlDataAdapter)
codeforces每日5题(均1700)-第三天
[untitled]
[paid promotion] collection of frequently asked questions, FAQ of recommended list
Flink 数据偶尔数据积压导致checkpoint失败
技术管理进阶——管理者如何进行梯队设计及建设
Redis设计与实现(一)| 数据结构 & 对象
Circuit analysis of current probe
Bind threads to run on a specific CPU logical kernel
Graffiti Wi Fi & ble SoC development slide strip
vite项目require语法兼容问题解决require is not defined
Unity 基础光照模型
About Lombok's @data annotation
电流探头的干扰源电流谱测试