Scalar Use
Hey there, please someone tell me what's the Scalar do in the following code ? and what's the use of it in general ?
Mat M(2,2, CV_8UC3, Scalar(0,0,255));
cout << "M = " << endl << " " << M << endl << endl;
Thanks
It initializes all pixels within the 2x2 image M with the color red as the Scalar(0,0,255) describes red in BGR ordering.
Scalar is a typedef for Scalar_<double>, which inherits from template<class _Tp> Vec<4,_Tp> ...
lol, now seriously: think of it as a Vec with variable size(up to 4 values), there can be Scalar(0), Scala(3,3,3), or Scalar(31,12,3,14);
it's mostly used to pass Color values, ranges, or similar in opencv
in your example above, a 2x2 rgb Mat is created and all pixels are set to Scalar(0,0,255) (blue)
Asked: 2013-02-21 07:40:22 -0600
Seen: 1,833 times
Last updated: Feb 21 '13