Why the output of cvtcolor(rgb to ycrcb) is different from manual function?

asked 2014-02-21 05:45:05 -0600

Dave143 gravatar image

updated 2014-02-21 06:32:59 -0600

berak gravatar image

Inbuilt Library function : cvtColor(input(in1), output(in2), CV_BGR2YCrCb, 0);

my manual function is as below

for(i=0;i<m;i++)< p="">

{

            for(j=0;j<n;j++)
   {
        in2.at<Vec3b>(i,j)[0]=.299*(in1.at<Vec3b>(i,j)[2])+.587*(in1.at<Vec3b>(i,j)[1])+.114*(in1.at<Vec3b>(i,j)[0]);
            in2.at<Vec3b>(i,j)[1]=((in1.at<Vec3b>(i,j)[2])-(in2.at<Vec3b>(i,j)[0]))*.713+128;
        in2.at<Vec3b>(i,j)[2]=((in1.at<Vec3b>(i,j)[0])-(in2.at<Vec3b>(i,j)[0]))*.564+128;

   }

}

Does anyone have any idea why there's such a difference?

edit retag flag offensive close merge delete