# Computer Graphics/Color Models

A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components. When this model is associated with a precise description of how the components are to be interpreted (viewing conditions, etc.), the resulting set of colors is called color space.

## The RGB Model

The RGB model is the most common model of color used in digital devices (the other being CMYK for printing, see below). Color digital displays are based on the RGB model of color. In this model, three channels of Red, Green and Blue colors respectively are combined to form a particular color. The total number of possible colors that can be formed in this way is dependent on color depth, which specifies the total number of bits assigned to the three channels. More the number of bits, more the colors that can be made. Typically, each channel is assigned 8 bits, which gives a total of 2$^{24}$ = 2$^4$×1024×1024 (more than 16 million) possible colors. Although historically, displays with lower color depth have been used in applications like games. For movies requiring visual effects (VFX), color depth used can be more than 24. Also, the colors combine in additive manner, unlike subtractive combination of paints.

## The HSB (or HSV) Model

The HSB model is based around three elements: "Hue", "Saturation", and "Brightness" (or Luminosity/Value). Brightness/Value represents how bright the color appears- the intensity of light, Hue stands for the pure color used. In this scheme, hue is represented by an angle in the color wheel. Red is 0 (or 360) degrees, Green is 120 degrees and Blue is 240 degrees. The other colors derived by combining these colors lie in between these ranges. For example, orange being a combination of red and yellow (red + green), would be close to 120/2/2 = 120/4 = 30 degrees and yellow itself would be close to 120/2 = 60 degrees. Similarly, magenta formed by combining red and blue would be close to (240+360)/2 = 300 degrees. Saturation is the the amount of hue present in the color. Less saturation implies more white and less hue. More saturation implies less white and more hue in the color. In HSB, 0% saturation stands for white. Otherwise, the color has some hue and is not completely white. 0% brightness means black. Otherwise, the color may be white (0% saturation) or be a color with hue (non-zero saturation).

## The HSL Model

The HSL (Hue, Saturation, Light) model is similar to HSB model, but not quite. The hue part remains the same as HSB. However, 0% saturation actually gives gray instead of white (as in HSB). Also, 0% light gives black and 100% light gives white (irrespective of hue or saturation). So for pure hue, a light value of 50% is used. In HSL, saturation is the amount of hue in gray. 100% saturation is full color. While 0% saturation is full gray.

## The CMYK Model

The CMYK model stands for Cyan, Magenta, Yellow and Key (which is just black). It is majorly used in printers and PDF documents.
Unlike other models discussed above, it is a subtractive color model because it deals with ink printed on paper instead of light forming pixels on digital display. Under this color model, the CMYK values describe how much from each of the above four colors need to be mixed and printed on the paper to get the desired color. Though black can be theoretically produced by mixing CMY, it is usually treated as a separate color. Black brings density and substance to the color.
Cyan ink absorbs red light while allowing blue and green, Magenta absorbs green light while allowing blue and red, and Yellow absorbs blue light while allowing red and green. So when cyan and magenta inks are mixed, both red (by Cyan) and green (by Magenta) components of white light (of the paper) are absorbed, leaving back only blue color. Thus mixing cyan and magenta ink produces blue ink. Similarly, mixing magenta and yellow would give red ink (both green and blue components of white light are absorbed). And mixing cyan and yellow would give green ink. The black pigment (K) absorbs all three RGB components of white light to varying degrees as desired.

## The XYZ Model

This standard was set in 1931 by the International Commission on Illumination(CIE).
It is not practically possible to create a perfect spectrum of all possible colors. Having said that, it is possible to get nearly all possible colors using a set of "primary colors". These primary colors are hypothetical. No real primary colors are defined.