Implementation of lab2xyz in opencv using c++
I am trying to implement Matlab function lab2xyz in opencv using c++, with whitepoint D50.But I got only Black image as output. Here is my code , please help me to resolve my problem.
`
float x=0.964221f,y=1.0f,z=0.825211f;
for(int i=0;i<rn;i++)
{
for(int j=0;j<cn;j++)
{
Vec3b intensity = image.at<Vec3b>(i,j);
L= intensity.val[2];
a= intensity.val[1];
b= intensity.val[0];
fy =(( L + 16. )/116.);
fx=((a / 500.)+ fy);
fz=(fy- (b/ 200.));
if( pow(fx,3.) > 0.008856 )
X = pow(fx,3.);
else
X = ( fx - 16. / 116. ) / 7.787;
if( pow(fy,3.) > 0.008856 )
Y= pow(fy,3.);
else
Y = ( fy- 16. / 116. ) / 7.787;
if( pow(fz,3.) > 0.008856 )
Z = pow(fz,3.);
else
Z= ( fz- 16. / 116. ) / 7.787;
X = X * x;
Y = Y * y;
Z = Z * z;
Result.at<Vec3b>(i,j)[2]=saturate_cast<uchar>(X);
Result.at<Vec3b>(i,j)[1]=saturate_cast<uchar>(Y);
Result.at<Vec3b>(i,j)[0]=saturate_cast<uchar>(Z);
} }`
How many exercises have to resolve as this one?
@LBerger: nearly 15
I don't think that's a good way to work (sorry for my bad english). All questions you have asked are quite similar. May be you should use this take some values in first and second color space and write a small program without opencv to find good function. When you've got it write your programm with opencv.
That's only my own opinion
PS I think that you have already check what's possible in opencv