color conversion

This is a discussion on color conversion within the Game Programming forums, part of the General Programming Boards category; Hey guys, I haven't been on the boards in a while. Anyway, I have been looking for a specific algorithm ...

color conversion

Hey guys, I haven't been on the boards in a while. Anyway, I have been looking for a specific algorithm for converting RGB colors to YUV. Here is the deal I have actually found many examples of how to do this (both ways), but the examples always have mystery numbers. For example:

As you can see there are numbers such as 0.257. Does anyone know how to derive these numbers? Or if in no one does know, then maybe you can help me with what I'm trying to do. Do you know how to calculate YUV for a 16-bit RGB value?

I think it might have something to do with the phosphors of the pixels in the monitor...but I don't remember, and if someone more enlightened posts something that sounds better, go with that (: Could you give me a refresher on what YUV stands for?

The new value Y = 0.299*R + 0.587*G + 0.114*B is called the luminance.
It is the value used by the monochrome monitors to represent an RGB colour.
Physiologically, it represents the intensity of an RGB colour perceived by
the eye.
You see that the formula for Y it's like a weighted-filter with different weights
for each spectral component: the eye is most sensitive to the Green component
then it follows the Red component and the last is the Blue component.

The values Cb = - 0.1687*R - 0.3313*G + 0.5 *B + 128
Cr = 0.5 *R - 0.4187*G - 0.0813*B + 128
are called the chromimance values and represent 2 coordinates in a system
which measures the nuance and saturation of the colour ([Approximately], these
values indicate how much blue and how much red is in that colour).
These 2 coordinates are called shortly the chrominance.

[Y,Cb,Cr] to [R,G,B] Conversion (The inverse of the previous transform)
--------------------------------
RGB can be computed directly from YCbCr ( 8-bit unsigned values) as follows:

Ah so I was on the right track with what I said. That is the most complete document about this subject I've seen so far. Thanks a bunch. I can always derive the 16-bit coefficients algebraically. Or even better yet I can still with how I am doing it now. Since my input images are 24-bit I just use the 24-bit rgb to yuv conversion do my compression and quantization routines and then take take the converted rgb and change that to 16-bit color. (I am doubtful that sharing this will be helpful to anyone but you never know).