其他分享
首页 > 其他分享> > Mat对象的创建和使用

Mat对象的创建和使用

作者:互联网

Mat对象创建

  //create one

  Mat src = Mat(255, 255, CV_8UC1);

  src=Scalar(0);      //创建一个全黑色的画布  (Scalar(0,0,255) 为红色,参数为(B,G,R),但创建时类型要改为CV_8UC3)

  imshow("src",src);

  

  //create two

  Mat src1 = Mat(Size(255, 255), CV_8UC3);

  src1=Scalar(255,0,255);      

  imshow("src1",src1);

 

  //create three
  Mat src2 = Mat::zeros(Size(255, 255), CV_8UC3);   //全为黑的通道
  imshow("src2", src2);

 

  //create three
  Mat src2 = Mat::zeros(Size(255, 255), CV_8UC3);
  imshow("src2", src2);

  

  Mat src3 = src2;
  Mat src4 = src2.clone(); //或Mat src4; src2.copyTo(src4);
  src4 = Scalar(0, 0, 255);

  Mat src5 = Mat::zeros(src.size(), src.type());
  imshow("src5", src5);


  waitKey(0);
  return 0;

标签:src,Mat,对象,创建,imshow,src2,CV,255
来源: https://www.cnblogs.com/djcsch2001/p/15407398.html