1、创建方式
> 1. Mat ()
> 2. Mat (int rows, int cols, int type)
> 3. Mat (Size size, int type)
> 4. Mat (int rows, int cols, int type, const Scalar &s)
> 5. Mat (Size size, int type, const Scalar &s)
> 6. Mat (int ndims, const int *sizes, int type)
> 7. Mat (int ndims, const int *sizes, int type, const Scalar &s)
原文链接:https://blog.csdn.net/lichaoqi1/article/details/112295817
读图片方式创建Mat
Mat A, C; //仅创建了头部
A = imread(argv[1], CV_LOAD_IMAGE_COLOR); //在此我们知道使用的方法(分配矩阵)
Mat B(A); //使用拷贝构造函数
C = A; //赋值运算符
创建带宽高的矩阵:
Scalar是bgr:
Mat imgM(200, 200, CV_8UC3, Scalar(255, 255, 255));
cv::imshow("bar_img", imgM);
cv::waitKey();
roi方式建图mat:
要在图像中创建兴趣区域 ( ROI) 您只需创建一个新头设置新边界:
Mat D (A, Rect(10, 10, 100, 100) ); // 用矩形界定
Mat E = A(Range:all(), Range(1,3)); // 用行和列来界定
拷贝:
Mat F = A.clone();
Mat G;
A.copyTo(G);