opencv矩阵与运算
时间: 2024-01-25 17:13:16 浏览: 103
以下是两种OpenCV矩阵与运算的例子:
1. 矩阵减法
```cpp
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
/* 矩阵减法 */
Mat m1 = (Mat_<uchar>(3, 2) << 200, 12, 21, 22, 31, 32);
Mat m2 = (Mat_<uchar>(3, 2) << 150, 11, 22, 21, 32, 31);
Mat dst = m1 - m2;
cout << "减法运算结果为:" << dst << endl;
return 0;
}
```
2. 矩阵点乘
```cpp
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
/* 矩阵点乘 */
Mat m1 = (Mat_<uchar>(3, 2) << 200, 12, 21, 22, 31, 32);
Mat m2 = (Mat_<uchar>(3, 2) << 150, 11, 22, 21, 32, 31);
Mat dst = m1.mul(m2);
cout << "点乘运算结果为:" << dst << endl;
return 0;
}
```
阅读全文