I am trying to convert RGB values to YCbCr color format. using Afroge library. but it gives result like this, for Y : 0.611, Cb : 0.15, Cr : -0.18. that means all the values < 1. but I need the values between 0 - 255. this is my code.
Bitmap bitmap = (Bitmap)pictureBox1.Image;
double xRatio = (double)bitmap.Width / (double)pictureBox1.Width;
double yRatio = (double)bitmap.Height / (double)pictureBox1.Height;
Color gotColor = bitmap.GetPixel((int)((double)mX * xRatio), (int)((double)mY * yRatio));
label1.Text = (" R : " + gotColor.R);
label2.Text = (" G : " + gotColor.G);
label3.Text = (" B : " + gotColor.B);
YCbCr ycrcb = new YCbCr();
RGB rgbcolor = new RGB(gotColor);
ycrcb.Y = YCbCr.FromRGB(rgbcolor).Y;
ycrcb.Cr = YCbCr.FromRGB(rgbcolor).Cr;
ycrcb.Cb = YCbCr.FromRGB(rgbcolor).Cb;
label4.Text = ycrcb.Y.ToString();
label5.Text = ycrcb.Cr.ToString();
label6.Text = ycrcb.Cb.ToString();
please help me.
Those are the standard ranges for YCrCb
However, you could just rescale the result into the 0 - 255 range
label4.Text = (ycrcb.Y *255).ToString();
label5.Text = ((ycrcb.Cr + 0.5)*255).ToString();
label6.Text = ((ycrcb.Cb + 0.5)*255).ToString();