OpenCV: How to convert CV_8UC1 mat to CV_8UC3

后端 未结 3 1040
后悔当初
后悔当初 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:51

    The convention is, that for the type CV_8UC3, the pixels values range from 0 to 255, and for type CV_32FC3 from 0.0 to 1.0. Thus you need to use a scaling factor of 255.0, instead of 1.0:

    Mat::convertTo(newImage, CV_32FC1, 255.0);
    

提交回复
热议问题