-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrixOperations.cpp
More file actions
50 lines (33 loc) · 1016 Bytes
/
matrixOperations.cpp
File metadata and controls
50 lines (33 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "opencv2/core.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main() {
Mat a = Mat(Size(5, 5), CV_32F);
Mat mz = Mat::zeros(5, 5, CV_32F);
Mat mo = Mat::ones(5, 5, CV_32F);
Mat eye = Mat::eye(5, 5, CV_32F);
Mat sumE = mo + eye;
Mat neg = mo - eye;
Mat mat2 = mo * 2;
Mat mat3 = mo.mul(eye);
Mat mat4 = eye * eye;
for (int i = 0; i < eye.rows; i++) {
for (int j = 0; j < eye.cols; j++) {
cout << mat3.at<float>(i,j) << " ";
}
cout << endl;
}
cout << endl;
cout << countNonZero(mat3) << endl;
cout << endl;
Scalar mean, stddev;
meanStdDev(mat3, mean, stddev);
cout << "Mean: " << mean[0] << " StdDev: " << stddev[0] << endl;
cout << endl;
double* minVal, maxVal;
int* minLoc, maxLoc;
minMaxLoc(mat3, minVal, maxVal, minLoc, maxLoc);
cout << "minmaclov: " << minVal << " " << maxVal << " " << minLoc << " " << maxLoc << endl;
return 0;
}