![Mat容器_第1张图片](http://img.e-com-net.com/image/info8/717c3f1c62714acf932ecafafe8e5e53.jpg)
![Mat容器_第2张图片](http://img.e-com-net.com/image/info8/a780f3a4c3804fa79a0d13de2eac2cc9.jpg)
![Mat容器_第3张图片](http://img.e-com-net.com/image/info8/be09f092251d4be1bc75d345c80b0bf6.jpg)
![Mat容器_第4张图片](http://img.e-com-net.com/image/info8/35d7156163a94645beafa60bc3e1b2c8.jpg)
![Mat容器_第5张图片](http://img.e-com-net.com/image/info8/d5d745ca59214b70ab41cd7415c0881a.jpg)
![Mat容器_第6张图片](http://img.e-com-net.com/image/info8/dd9291f325874626a98c9a970458b9b0.jpg)
![Mat容器_第7张图片](http://img.e-com-net.com/image/info8/dfdce62fc621491f9f8e1880eb99fa0a.jpg)
![Mat容器_第8张图片](http://img.e-com-net.com/image/info8/7b0f216f531d434f8127df0305a4d567.jpg)
#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;
}
![Mat容器_第9张图片](http://img.e-com-net.com/image/info8/89b26843a60c43f591f4b9ad3afd6b62.jpg)
#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;
}