Given a non-empty cv::Mat img
of some size, we can fill it to a solid color in several ways:
img = cv::Scalar(blueVal,greenVal,redVal);
or, the more general, mask supporting, cv::Mat::setTo()
:
img.setTo(cv::Scalar(blueVal,greenVal,redVal));
If you are using the older OpenCV C API with IplImage* img
:
Use:
cvSet(img, CV_RGB(redVal,greenVal,blueVal));