Converting an OpenCV BGR 8-bit Image to CIE L*a*b*

后端 未结 4 748
既然无缘
既然无缘 2020-12-30 05:29

I am trying to convert a given Mat representing an RGB image with 8-bit depth to Lab using the function provided in the documentation:

4条回答
  •  时光说笑
    2020-12-30 06:15

    In case anyone runs into the same issue:

    Please note that in OpenCV (2.4.13), you can not convert CV_32FC3 BGR images into the Lab color space. That is to say:

    //this->xImage is CV_8UC3
    this->xImage.convertTo(FloatPrecisionImage, CV_32FC3);
    Mat result;
    cvtColor(FloatPrecisionImage, result, COLOR_BGR2Lab);
    this->xImage = result;
    

    will not work while

    Mat result;
    cvtColor(this->xImage, result, COLOR_BGR2Lab);
    result.convertTo(this->xImage, CV_32FC3);
    

    works like a charm. I did not track down the reason for said behavior; however it seems off to me, because this in effect puts limits on the image's quality.

提交回复
热议问题