I need to convert RGB to YCbCr for my final project, and I'm trying to do this (I'm programming in C):
int* converter_RGB_para_YCbCr(int R, int G, int B){ int* YCbCr = (int*) malloc(3 * sizeof(int)); double delta = 128.0;
But this does not work for me!
I compared cvCvtColor (from the OpenCv library) and the results did not match:
R = 88, G = 76, B = 78 cvCvtColor: Y = 80, Cb = 127, Cr = 134 myfunction: Y = 382, Cb = 132, Cr = 132 (cr and cr are always equal!)
I really need help with this, I have been trying to do this for a long time, and I could not find an answer to my doubts.
Do you guys think I misunderstood the RGB values? I do like this:
uchar B = CV_IMAGE_ELEM(img_RGB, uchar, linha, coluna * 3); uchar G = CV_IMAGE_ELEM(img_RGB, uchar, linha, coluna * 3 + 1); uchar R = CV_IMAGE_ELEM(img_RGB, uchar, linha, coluna * 3 + 2);
Then I call my conversion function as follows:
converter_RGB_para_YCbCr(R, G, B);
My function expects int R, int G, int B, but I skip uchar B, uchar G, uchar R. is this normal?