Constructing a Mat class can be done in numerous ways. At the time of writing this book, the Mat class has over twenty different constructors. Some of them are just convenient constructor functions, but some others are required in order to create three and more dimensional arrays for instance. Here are some of the most widely used constructors and examples of how to use them:
Create a 10x10 matrix, with each element a single channel 8-bit unsigned integer (or byte):
Mat matrix(10, 10, CV_8UC(1));
Create the same matrix and initialize all of its elements with the value of 0:
Mat matrix(10, 10, CV_8UC(1), Scalar(0);
The first parameter in the constructors shown in the preceding code is the number of ...