







#include //the basic building blocks of the library
#include //provides functions for reading and writing
#include //contains the functions to show an image in a window
#include
using namespace cv;
using namespace std;
int main()
{
Mat a = (cv::Mat_(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);
Mat c0(5, 5, CV_8UC1, Scalar(4, 5, 6));
Mat c1(5, 5, CV_8UC2, Scalar(4, 5, 6));
Mat c2(5, 5, CV_8UC3, Scalar(4, 5, 6));
cout << a.at(0, 0) << endl; // 1
cout << (int)c0.at(0, 1) << endl; // 4
Vec2b vc = c1.at(0, 1);
cout << vc << endl; //[4, 5]
cout << (int)vc[0] << endl; // 4
cout << (int)c1.at(1, 1)[1] << endl; // 5
cout << (int)(*(c2.data + c2.step[0]*2 + c2.step[1]*1 + 2)); // 6
return 0;
}

#include //the basic building blocks of the library
#include //the basic building blocks of the library
#include //provides functions for reading and writing
#include //contains the functions to show an image in a window
#include
using namespace cv;
using namespace std;
int main()
{
Mat c0(3, 3, CV_32FC3, Scalar(4, 5, 6));
Mat c1(3, 3, CV_32FC3, Scalar(5, 6, 4));
Mat c2(3, 3, CV_32FC3, Scalar(6, 4, 5));
cout << "和:" << c0 + c1 << endl;
cout << "差:" << c0 - c1 << endl;
cout << "数乘:" << 2 * c0 << endl;
cout << "数除:" << c0 / 2.0 << endl;
cout << "减数:" << c0 - 1.0 << endl;
cout << "对应位相乘:" << endl << c0.mul(c1) << endl;
cout << "两个矩阵最小值:" << endl << min(c0, c1) << endl;
return 0;
}