opencv中scalar--通道像素填充

其作用,就是为每个通道的像素赋值,取值范围为0~255;

#include   
  
using namespace cv;

int main()
{
Mat image1(600, 500, CV_8UC3, Scalar(0,0,255)); //Scalar函数为每个通道填充像素值(3通道)
Mat image2(600, 500, CV_8U, Scalar(0));//(单通道)
Mat image3(600, 500, CV_8UC3);
randu(image3, Scalar::all(0), Scalar::all(255));//随机产生通道的像素值,下限为0,上限为255

imshow("Image_c3", image1);
imshow("Image_c1", image2);
imshow("Image_c3_r", image3);

waitKey(0);

return 0;

}


opencv中scalar--通道像素填充_第1张图片

你可能感兴趣的:(opencv)