Ask Your Question

Tess's profile - activity

2015-09-09 04:27:49 -0600 received badge  Enthusiast
2015-09-08 05:09:11 -0600 asked a question Pixel intencity difference in opencv and Matlab

I am trying to implement various Matlab functions rgb2lab in opencv. I got output images(in opencv) similar to Matlab. But their pixel values are different. For example output pixels values of 2x2 pixel image:

  1. Opencv pixel values : [255, 255, 255, 255, 255, 255; 255, 255, 255, 255, 255, 255]
  2. Matlab pixel values : e(:,:,1) = 51.0815 51.0815 51.0815 51.0815 e(:,:,2) = 33.3777 33.3777 33.3777 33.3777 e(:,:,3) = 10.6660 10.6660 10.6660 10.6660 Please help me to resolve my problem. How it happen?
2015-09-07 05:20:35 -0600 commented question Implementation of various matlab functions in opencv

@LBerger: Sorry, I said I can save the image using ' imwrite' function. But I cannot show my output image using 'imshow' function(This is my problem).

2015-09-06 22:35:16 -0600 asked a question Implementation of various matlab functions in opencv

I am trying to implement various Matlab functions in opencv using c++. These are the functions lab2uint8 , lab2uint16 , lab2double , xyz2double , xyz2uint16. These conversions I did by 'convertTo' function. For example: lab2uint8 conversion ' lab.convertTo(Result,CV_8U)' . Then I can't show my Result image by imshow function. But I can save the Result image by imwrite function. I know I am troubling you by repeatedly asking similar type of questions, sorry for that.

2015-09-06 14:35:41 -0600 commented question Implementation of lab2xyz in opencv using c++

@LBerger: nearly 15

2015-09-06 13:44:43 -0600 asked a question 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); 
  }  }`
2015-09-05 12:23:24 -0600 asked a question How to find the color space of an image

I am trying to do diffrent colorspace conversion on images (rgb2lab,rgb2ntsc..etc) in opencv using c++. After the conversion I just compare my output image with Matlab output image. Comparison is just done by normal vision. but I know that in the case of images normal vision comparison is not accurate. How can I find which colorspace(rgb,ntsc,lab,xyz) my image belong to?. Any standard method or technique for finding the colorspace of a image?

I am totally new in image processing domain.So please give proper guidance in image processing using openCV...

2015-09-05 03:31:53 -0600 commented question Implementation of rgb2lab in opencv using c++.

@LBerger @berak: Sorry to ask you again...But could you please tell me how to indent the code, where to find the icon 101010?

2015-09-05 00:12:27 -0600 asked a question Implementation of rgb2lab in opencv using c++.
   I am trying to implement Matlab function rgb2lab in opencv using c++. I used opencv cvtcolor function for the

implementation. Then I did another implementation.Here is my code:

for(int i=0;i<rn;i++)
    {
      for(int j=0;j<cn;j++)
       {
         Vec3b intensity = image.at<Vec3b>(i,j);
         R= intensity.val[2];
         r=R/255.f;
         G= intensity.val[1];
         g=G/255.f;
         B= intensity.val[0];
         b=B/255.f;
         if (r<= 0.04045)
               r= r/12;
         else
               r= (float)pow((r+0.055)/1.055,2.4);
         if (g <= 0.04045)
               g= g/12;
         else
               g= (float)pow((g+0.055)/1.055,2.4);
         if (b<= 0.04045)
               b= b/12;
         else
               b = (float)pow((b+0.055)/1.055,2.4);
           X=0.436052025f*r+ 0.385081593f*g + 0.143087414f *b;
           Y= 0.222491598f*r+ 0.71688606f *g + 0.060621486f *b;
           Z=0.013929122f*r+ 0.097097002f*g + 0.71418547f  *b;
           xr = X/Xr;
           yr = Y/Yr;
           zr = Z/Zr;
           if ( xr > eps )
              fx =  (float)(xr, 1/3.);
           else
              fx = (float) ((k * xr + 16.) / 116.);
           if ( yr > eps )
              fy =  (float)pow(yr, 1/3.);
           else
              fy = (float) ((k * yr + 16.) / 116.);
           if ( zr > eps )
              fz =  (float)pow(zr, 1/3.);
           else
              fz = (float) ((k * zr + 16.) / 116);
           Ls = ( 116 * fy ) - 16;
           as = 500*(fx-fy);
           bs = 200*(fy-fz);
           Result.at<Vec3b>(i,j)[0]=saturate_cast<uchar>(2.55*Ls + .5);
           Result.at<Vec3b>(i,j)[1]=saturate_cast<uchar>(as + .5);
           Result.at<Vec3b>(i,j)[2]=saturate_cast<uchar>(bs + .5);
        }
     }

Both implementation results are not similar to Matlab output image. Please find the 3 image files : 1)my first output image(using cvtcolor),2) second output image(using above code) and 3) third matlab ouput image. Please anyone help me to find the correct way for implementation.

cvtColor-outputsecond implementationMatlab output image

2015-09-04 15:37:19 -0600 commented question Implementation of rgb2xyz in opencv using c++

@LorenaGdL: My black output problem is solved.Thanks..

2015-09-04 15:01:00 -0600 received badge  Self-Learner (source)
2015-09-04 14:49:06 -0600 commented question Implementation of rgb2xyz in opencv using c++

@LorenaGdL: Sorry, I just used the matlab rgb2xyz function for generating output image.

2015-09-04 14:44:24 -0600 commented question Implementation of Matlab function rgb2ntsc in opencv using c++

@ berak :Code:-

Mat image =imread(argv[1],1);
Mat k=(Mat_<float>(3,3) << 0.299,0.587,0.114, 0.596,-0.274,-0.322,0.211,-0.523,0.312);
Mat Result;
cvtColor(image,image,CV_BGR2RGB);
transform(image,Result,k); 
cvtColor(Result,Result,CV_RGB2BGR);
2015-09-04 14:10:19 -0600 asked a question Implementation of rgb2xyz in opencv using c++

I am trying to implement matlab rgb2xyz function in opencv using c++. I used cvtColor function for implementation. But my output image is not similar to Matlab output image.Should I use any other function or operations on image ?Here is my input image ,matlab output image and my output image.input imageMatlab output imageMy output image Hai... I got 1 more code for the implementation of rgb2xyz.But it gave me black output image. Here is the code.

 for(int i=0;i<rn;i++)
     {
       for(int j=0;j<cn;j++)
        {
         Vec3b intensity = image.at<Vec3b>(i,j);
         R= intensity.val[2];
         G= intensity.val[1];
         B= intensity.val[0];
         r = R/255.f; //R 0..1
         g = G/255.f; //G 0..1
         b = B/255.f; //B 0..1
         if (r <= 0.04045)
             r = r/12;
         else
             r = (float)pow((r+0.055)/1.055,2.4);
         if (g <= 0.04045)
             g = g/12;
         else
             g = (float)pow((g+0.055)/1.055,2.4);
         if (b <= 0.04045)
             b = b/12;
         else
             b = (float)pow((b+0.055)/1.055,2.4);
         X =  0.436052025f*r     + 0.385081593f*g + 0.143087414f *b;
         Y =  0.222491598f*r     + 0.71688606f *g + 0.060621486f *b;
         Z =  0.013929122f*r     + 0.097097002f*g + 0.71418547f  *b;
         Result.at<Vec3b>(i,j)[0]=(float)X;
         Result.at<Vec3b>(i,j)[1]=(float)Y; 
         Result.at<Vec3b>(i,j)[2]=(float)Z; 
      }
  }
2015-09-04 13:37:01 -0600 commented question Implementation of Matlab function rgb2ntsc in opencv using c++

@berak:transform, helped me.... thanks.

2015-09-04 05:05:18 -0600 received badge  Editor (source)
2015-09-04 05:00:29 -0600 asked a question Implementation of Matlab function rgb2ntsc in opencv using c++

I am trying to implement rgb2ntsc colorspace conversion in OpenCV using C++.

for(int i=0;i<rn;i++) {
    for(int j=0;j<cn;j++) {
        Vec3b intensity = image.at<Vec3b>(i,j);
        R = intensity.val[2];
        G = intensity.val[1];
        B = intensity.val[0];
        Y = 0.299*R+0.587*G+0.114*B;
        I = 0.596*R-0.274*G-0.322*B;
        Q = 0.211*R-0.523*G+0.312*B;
        Result.at<Vec3b>(i,j)[0] = (float)Y;
        Result.at<Vec3b>(i,j)[1] = (float)I;
        Result.at<Vec3b>(i,j)[2] = (float)Q;
    }
}

I have done this for the implementation of rgb2ntsc. But my output image is not similar to the output of Matlab's rgb2ntsc function. Here are my input image, output image and matlab output image. Can I do any additional operation?

input image My output image Matlab output image