OpenCV cv::Mat 'ones' for multi-channel matrix?

后端 未结 2 595
孤街浪徒
孤街浪徒 2021-01-17 11:34

When working with 1-channel (e.g. CV_8UC1) Mat objects in OpenCV, this creates a Mat of all ones: cv::Mat img = cv::Mat::ones(x,y,CV_8UC1).

2条回答
  •  余生分开走
    2021-01-17 12:23

    You can also initialize like this:

    Mat img;
    
    /// Lots of stuff here ...
    
    // Need to initialize again for some reason:
    img = Mat::Mat(Size(width, height), CV_8UC3, CV_RGB(255,255,255));
    

提交回复
热议问题