Reputation: 21
Hello i want to ask what is this line of code do?
Mat res(img.rows, img.cols, CV_8UC1, Scalar(0,0,0));
i'm guessing it's making matrix of image rows and columns but i still don't understand what's the Scalar(0,0,0) for?
Upvotes: 2
Views: 674
Reputation: 4905
From the documentation of OpenCV, you are using the fourth constructor:
Mat (int rows, int cols, int type, const Scalar &s);
The third argument is the array type for the elements of the matrix. You are using CV_8UC1: 8-bit single-channel array.
The fourth argument is an optional value to initialize each matrix element with. Scalar is simmilar to a 4x1 vector. However, since you have specified a single channel, only the first value will be copied to the matrix elements. If you had specified more channels, the remaining elements of Scalar would be used.
Upvotes: 2