OpenCV: How to convert CV_8UC1 mat to CV_8UC3

后端 未结 3 1046
后悔当初
后悔当初 2021-01-04 05:25

How to convert CV_8UC1 Mat to CV_8UC3 with OpenCV?

Mat dst;
Mat src(height, width, CV_8UC1, (unsigned char*) captureClient->data());
src.convertTo(dst, CV         


        
3条回答
  •  青春惊慌失措
    2021-01-04 05:34

    From the documentation on convertTo

    void Mat::convertTo(Mat& m, int rtype, double alpha=1, double beta=0) const

    rtype – The desired destination matrix type, or rather, the depth (since the number of channels will be the same with the source one). If rtype is negative, the destination matrix will have the same type as the source.

    You want to create a matrix for each of the 3 channels you want to create and then use the merge function. See the answers to this question

提交回复
热议问题