首页 > 其他 > 详细

1、Mat类的属性、方法

时间:2019-11-13 18:22:39      阅读:159      评论:0      收藏:0      [点我收藏+]

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;

技术分享图片

1、Mat类的属性、方法

原文:https://www.cnblogs.com/xixixing/p/11851342.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!