Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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); 
  }

}

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&lt;cn;j++)" {="" vec3b="" intensity="image.at&lt;Vec3b">(i,j);

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); 
  }
}  }`

}

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&lt;cn;j++)" {="" vec3b="" intensity="image.at&lt;Vec3b">(i,j);

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); 
  }  }`