huehuehuehue
huehuehuehue

Reputation: 305

What does the cv::Scalar type mean?

I have to find the sum of the elements in a Mat, the sum function of OpenCV returns a cv::Scalar but how should I interpret it ?

Upvotes: 11

Views: 31799

Answers (1)

dynamic
dynamic

Reputation: 48101

cv::Scalar is used because the image can be multi-channel. For this reason the the white color is represented as:

cv::Scalar(255,255,255);

For access a particular element you can simply use [] operator:

cv::Scalar myWhite(255,255,255);
cout << myWhite[0] << endl;

For the sum, each channel will represent the sum of that particular channel.

Upvotes: 21

Related Questions