Getting black image for 16 bit image.
void convert_BGR2Lab(Mat &bgrMat, Mat &labMat)
{
if (bgrMat.depth() == CV_8U)
{
cvtColor(bgrMat, labMat, COLOR_BGR2Lab);
}
else if(bgrMat.depth() == CV_16U)
{
cv::Mat float_image;
bgrMat.convertTo(float_image, CV_32F, 1.0 / 65535.0);
cv::Mat lab_image;
cv::cvtColor(float_image, lab_image, cv::COLOR_BGR2Lab);
lab_image.convertTo(labMat, CV_16U, 65535.0);
}
}
I am trying to convert CV_16U BGR to CV_16U Lab.
i have tried with converting to 8 bit first, and it works.
void convert_BGR2Lab(Mat &bgrMat, Mat &labMat)
{
Mat bgr8bit;
bgrMat.convertTo(bgr8bit, CV_8U, 1.0 / 256.0);
Mat lab8bit;
cvtColor(bgr8bit, lab8bit, COLOR_BGR2Lab);
lab8bit.convertTo(labMat, CV_16U, 256.0);
}
but when i convert it to 32 bit, it does not work
getting black image from the code below
void convert_BGR2Lab(Mat &bgrMat, Mat &labMat)
{
cv::Mat float_image;
bgrMat.convertTo(float_image, CV_32F, 1.0 / 65535.0);
cv::Mat lab_image;
cv::cvtColor(float_image, lab_image, cv::COLOR_BGR2Lab);
lab_image.convertTo(labMat, CV_16U, 65535.0);
}
Any solution to convert 16 bit BGR to 16 bit Lab would be helpful.
Thank you.