RGB
RGB mixes red, green and blue light, like the pixels of a display and the filters of a camera sensor. It is the space images are stored in, but its channels are strongly correlated: every channel carries brightness, so a shadow changes all three at once. Values here are sRGB-encoded, as in image files (see the gamma demo).
HSV
HSV describes a color by its hue (the angle on the color wheel), its saturation (how far it is from gray) and its value (the brightest channel):
Hue is useful for picking colors and for segmenting objects by color, since it stays roughly the same when the light gets brighter or darker. But it is undefined for grays, where , and it wraps around: 359° and 1° are both red.
YCbCr
YCbCr separates the luma from two color differences, (blue minus luma) and (red minus luma). It is a linear transformation of RGB, here in the full-range form used by JPEG with values from 0 to 255:
Gray has . Image and video compression use this split because the eye resolves detail in brightness much better than in color, see chroma subsampling.
Luma is often loosely called luminance, but the two are different. Luma (strictly written ) is a weighted sum of the gamma-encoded values R, G, B, as stored in the image. Luminance is the same kind of sum of linear light, with its own weights ( for sRGB): the of the CIE XYZ space below. Luma is cheaper to compute and close enough for compression, but it is not a physical quantity.
L*a*b*
CIE L*a*b* is designed so that equal distances correspond to roughly equal perceived differences. is lightness from 0 to 100, runs from green to red and from blue to yellow. It is computed from linear RGB via the CIE XYZ space, whose is the luminance, and a cube root that mimics the eye's response:
with (plus a linear piece near 0) and the white point. The distance between two colors in L*a*b* is a simple measure of how different they look.
Interpolation
A straight line between two colors is a different path through the colors in every space. In RGB, red to green passes through a dull olive. HSV keeps the saturation and walks around the color wheel instead, and L*a*b* changes lightness evenly. Some points on a straight line in L*a*b* have no RGB equivalent; these are clipped to the nearest displayable value.
Try this
- Compare the RGB and YCbCr strips. They are identical: YCbCr is a linear map of RGB, so straight lines stay straight lines.
- Set A to red and B to green. RGB goes through a dark olive, HSV through a bright yellow.
- Blend a saturated color with gray or white in HSV. Gray has no hue, so only saturation and value change.
- Look at the H channel of the test chart. Red appears both black and white, because hue wraps around at 0° = 360°.
- Show the YCbCr channels of the landscape. Almost all detail is in Y, while Cb and Cr are smooth.
- Set A to pure blue
#0000ffand B to pure yellow#ffff00. Both have , but is about 32 versus 97: V is not perceived brightness.