2 减法运算
- 两个矩阵对应位置的数值相减
2.1 使用“-”运算符
- 注意数据类型
2.2 使用函数subtract
void subtract(InputArray src1,InputArray src2,OutputArray dst,InputArray mask=noArray(),int dtype=-1);
#include <opencv2/core/core.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main(){
Mat src1 = (Mat_<uchar>(2, 3) << 23, 123, 90, 100, 250, 0);
Mat src2 = (Mat_<float>(2, 3) << 125, 150, 60, 100, 10, 40);
Mat dst;
subtract(src1, src2, dst, Mat(), CV_64FC1);
cout << src1 << endl;
cout << src2 << endl;
cout << dst << endl;
return 0;
}