opencv中Mat数据结构

1 Mat类结构

Mat是matrix矩阵的简写,Mat类中数据部分主要分为两个部分:头和数据指针。头中定义一些矩阵的行数、列数、通道数、维度等信息;数据指针中定义uchar* data的数据地址。函数部分主要包括大量构造函数、大量模版函数以及一些非模版函数。
我们知道在c++中类实例化的对象中,真正拥有的是数据部分。

1.1 数据部分

int flags; //signature
int dims; //维数,灰度图像二维,rgb图像三维
int rows, cols; //行数和列数,这里说的是逻辑上的矩阵的行数和列数,而不是物理存储时
uchar* data; // 矩阵元素数据的首地址,类型是uchar*,在c/c++中通常最小的数据处理大小是一个字节

//图像ROI的辅助指针
uchar* datastart;
uchar* dataend;
uchar* datalimit;

MSize size; //一行含有的字节数,MSize和MStep是定义的结构体
MStep step;
//...

1.2 函数部分

1.2.1 构造函数和析构函数

Mat();
Mat(int rows, int cols, int type);
Mat(Size size, int type);
Mat(int rows, int cols, int type, const Scalar& s);
Mat(Size size, int type, const Scalar& s);
Mat(int ndims, const int* sizes, int type);
Mat(int ndims, const int* sizes, int type, const Scalar& s);

Mat(const Mat& m);

Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP);
Mat(Size size, int type, void* data, size_t step=AUTO_STEP);
Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);

Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all());
Mat(const Mat& m, const Rect& roi);
Mat(const Mat& m, const Range* ranges);

Mat(const IplImage* img, bool
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值