Mat类常用的构造函数

Mat类
Mat类是一个图像类,也是一种通用矩阵类。

  • 无参构造方法:
    Mat::Mat()

  • 创建行数为rows,列为col,类型为type的图像(图像元素类型,如CV_8UC3等)
    Mat::Mat(int rows, int cols, int type)

  • 创建大小为size,类型为type的图像
    Mat::Mat(Size size, int type)

  • 创建行数为 rows,列数为 col,类型为 type 的图像,并将所有元素初始
    化为值 s
    Mat::Mat(int rows, int cols, int type, const Scalar& s)

  • 创建大小为 size,类型为 type 的图像,并将所有元素初始化为值 s
    Mat::Mat(Size size, int type, const Scalar& s)

  • 将 m 赋值给新创建的对象,此处不会对图像数据进行复制,m 和新对象
    共用图像数据
    Mat::Mat(const Mat& m)

  • 创建行数为 rows,列数为 col,类型为 type 的图像,此构造函数不创建
    图像数据所需内存,而是直接使用 data 所指内存,图像的行步长由 step
    指定
    Mat::Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP)

  • 创建大小为 size,类型为 type 的图像,此构造函数不创建图像数据所需
    内存,而是直接使用 data 所指内存,图像的行步长由 step 指定
    Mat::Mat(Size size, int type, void* data, size_t step=AUTO_STEP)

  • 创建的新图像为 m 的一部分,具体的范围由 rowRange 和 colRange 指
    定,此构造函数也不进行图像数据的复制操作,新图像与 m 共用图像数

    Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange)
  • 创建的新图像为 m 的一部分,具体的范围 roi 指定,此构造函数也不进
    行图像数据的复制操作,新图像与 m 共用图像数据
    Mat::Mat(const Mat& m, const Rect& roi)

猜你喜欢

转载自blog.csdn.net/u013539952/article/details/80002434
今日推荐