Mat类分有两个部分:矩阵头和指向矩阵数据部分的指针
Mat类的属性:
- rows 矩阵的行数
- cols 矩阵的列数
- dims 矩阵的维度,例如5*6矩阵是二维矩阵,则dims=2,三维矩阵dims=3.
- data uchar类型的指针,指向Mat数据矩阵的首地址。
Mat类的方法:
- size() 矩阵的大小,宽×高(列×行)
- channels() 矩阵元素拥有的通道数,例如常见的彩色图像,每一个像素由RGB三部分组成,则channels = 3
【参考】
https://www.cnblogs.com/faith0217/articles/4708877.html
【案例】
Mat kernel = (Mat_<char>(2, 3) << 0, -1, 0,-1, 5, -1); cout << kernel << endl; cout << kernel.rows << endl; cout << kernel.cols << endl; cout << kernel.size()<<endl; cout << kernel.channels() << endl; cout << kernel.dims << endl; waitKey(); return 0;