There are different methods for encoding the color of a pixel. Some of the more common ones are discussed here.
The RGB system is based off the fact that white light (and therefore its consituents) can be made up of just three primary colors -
A more common usage of RGB color space, includes using unsigned char
for the storage of a pixel per channel. An unsigned char
is 1 byte (8 bit color depth), and allows for a range from 0 to 255.
This allows for
Additionally, adding an alpha channel for transparency gives us the RGBA color space. Alpha 0 is transparent and alpha 1 is fully opaque. PNG supports both 24bit RGB and 32bit RGBA.
HSV is a human friendly color space. Only one of its three channels, hue(H) is used for representing the main base color. The other two channels are saturation(S) and value(V).
This is a subtractive color model unlike RGB. Pigments in real life, follow subtractive coloring. Mixing perfectly red, green and blue paints will yield black paint. CMYK is more realistic, with respect to pigments, and is therefore used with printers. The fourth channel, key(K) can be thought of as "darkness" or "inverted brigthness". 0% would mean no black pigment and 100% would mean it is fully black.
The simplest explanation I could come up with for CMYK, is that we start off with a white pigment. So CMYK(0, 0, 0, 0)
is pure white.
Cyan at 1, would imply that we applied a cyan pigment, and therefore the constituents of cyan - blue and green are the only wavelengths reflected, and red is absorbed.
CMYK(1, 0, 0, 0)
can be thought of as "subtract red light from white, resulting in blue + green = cyan"CMYK(1, 1, 0, 0)
for example, would mean "subtract red and green from white, resulting in blue"