cv::Scalar used because the image can be multi-channel. For this reason, white is represented as:
cv::Scalar(255,255,255);
To access a specific item, you can simply use the [] operator :
cv::Scalar myWhite(255,255,255); cout << myWhite[0] << endl;
For the sum, each channel will represent the sum of that particular channel.
source share