#include "stdafx.h"
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;int main() {
/*
CV_8UC1 8位1通道
CV_8UC3 8位3通道
CV_32FC1 32位1通道
CV_64FC1 64位1通道
*///创建Mat图像(像素值自定义)
Mat MM(3, 3, CV_8UC3, Scalar(128, 3, 0));// 参数(int rows, int cols, int type, const Scalar& s)
cout << "MM = " << endl << " " << MM << endl;//创建Mat图像(像素值205)
Mat MC;
MC.create(3, 3, CV_8UC1);
cout << "MC = " << endl << " " << MC << endl;//创建Mat图像(像素值单位矩阵)
Mat E = Mat::eye(3, 3, CV_8UC3);
cout << "E = " << endl << " " << E << endl;//创建Mat图像(像素值全1矩阵)
Mat O = Mat::ones(3, 3, CV_32FC1);
cout << "O = " << endl << " " << O << endl;//创建Mat图像(像素值全0矩阵)
Mat Z = Mat::zeros(3, 3, CV_64FC1);
cout << "Z = " << endl << " " << Z << endl;waitKey();
system("pause");
return 0;
}
Out 图像: