From opencv documentation i found that the Lab* color space has limited value for each variable as following :
0 < L < 100
-127 < a < 127
-127 < b < 127
I wrote a code which read and convert an image of type BGR to Lab* color space. When i show value of L,a and b i found that values are out of range (all of them)
For example in a pixel (y,x) the value of b is 150 but from the opencv 2.4.13 documentation b must be between -127 and 127. The code is the following :
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv){
Mat input, Lab_img;
input = imread("E:\\Walid\\Images\\b2.jpg");
cvtColor(input, Lab_img, CV_BGR2Lab);
namedWindow("ORIGINAL", WINDOW_AUTOSIZE);
namedWindow("Lab", WINDOW_AUTOSIZE);
for (int y = 0; y < Lab_img.rows; y++)
{
for (int x = 0; x < Lab_img.cols; x++)
{
Vec3b intensity = Lab_img.at<Vec3b>(y, x);
double L = intensity.val[0];
double a = intensity.val[1];
double b = intensity.val[2];
cout << b << std::endl;
}
}
imshow("ORIGINAL", input);
imshow("Lab", Lab_img);
waitKey(0);
return 0;
}
Here is reference for cvtColor In section RGB <-> CIE L*a*b* it says:
This outputs 0 <= L <= 100, -127 <= a <= 127, -127 <= b <= 127 . The values are then converted to the destination data type: For 8-bit images L = L*255/100, a = a + 128, b = b + 128.