当前位置:网站首页>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
边栏推荐
猜你喜欢
Mmcv expanding CUDA operator beginner level chapter
Introduction to the runner of mmcv
Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
【NVMe2.0b 14】NVMe Admin Command Set
Occasionally, Flink data is overstocked, resulting in checkpoint failure
Interference source current spectrum test of current probe
Resnet50+fpn for mmdet line by line code interpretation
[untitled]
Codeworks 5 questions per day (1700 for each) - the third day
电流探头电路分析
随机推荐
Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)
Understanding society at the age of 14 - reading notes on "happiness at work"
Bind threads to run on a specific CPU logical kernel
[kotlin collaboration process] complete the advanced kotlin collaboration process
Interpretation of orientedrcnn papers
基于Svelte3.x桌面端UI组件库Svelte UI
Redis design and Implementation (VIII) | transaction
Mmdet line by line deltaxywhbboxcoder
Is it safe to open an account? How can anyone say that it is not reliable.
小心transmittable-thread-local的这个坑
Vite project require syntax compatibility problem solving require is not defined
[untitled]
Circuit analysis of current probe
mysql基础入门 day3 动力节点[老杜]课堂笔记
【NVMe2.0b 14-4】Directive Send/Receive command
[untitled]
Detailed explanation of pipline of mmdetection
Redis设计与实现(五)| Sentinel哨兵
vim 从嫌弃到依赖(21)——跨文件搜索
vite項目require語法兼容問題解决require is not defined