Color Spaces

This topic describes the representation of colors on the computer, namely, about color spaces.

Color is a complex phenomenon. To describe it, a number of color models were invented. Each of them has its merits and demerits. Some of them can be achieved because of radiating, other ones are generated by reflection. Some of these models represent colors independent from the device where the color is reproduced, others are dependent on the device. A set of colors which can be represented by some color model is called a color space. The most widespread color models (supported by Graphics Mill) are examined below.

RGB Model

RGB is the most popular color model. Each pixel is represented as a combination of three primary colors - Red, Green and Blue. To produce a certain color, red, green and blue colors are added in some proportion. That's why this model is called an additive model. When all three components are zero, we get black, and vice versa, when all the components have maximum value, we get white. It is shown on the figure below:

RGB model

This method of color representation is widely used in computer monitors, television sets, and similar devices (which radiate). Each component specifies an intensity of red, green or blue phosphor. That's why this color model is so popular - it is natural for displaying images on computer monitors.

This color model is device-dependent. Different monitors (even if they have the same vendor and model) display colors differently. Even the same device displays color differently as time goes by (because of phosphors aging, quality loss and so on).

CMY(K) Model

Not all the colors are the result of illuminating. Most of objects in the world do not radiate, but nevertheless look colorful. These objects are seen in color because of the light reflection. When the light falls onto an object, some wavelengths are absorbed by the object, some of them are reflected. When all the wavelengths are reflected (and nothing is absorbed) we get white. When all the wavelengths are absorbed (and nothing is reflected), we get black. If we need to get a primary color from the RGB model, we need to absorb two other primary colors. In fact, we subtract colors from white to get the color we need. That's why this model is called a subtractive model (compared with the additive RGB, where we add colors to a black base).

The subtractive analogue of RGB is the color model called CMY. CMY uses Cyan, Magenta and Yellow as primary colors. These colors are selected as primary because cyan is obtained when we subtract red, magenta - when we subtract green, and yellow - when we subtract blue (so we can say that CMY is inverted RGB). This is demonstrated on the figure below. Note, colors of this model are much less saturated than in RGB. This is caused by peculiarities of the subtraction model - if an object does not radiate, it is difficult to get a bright and saturated color.

CMYK model

In theory the subtractive CMY model is suitable for printing. Each component should specify the amount of cyan, magenta or yellow ink. To get black we should mix all these inks. However in practice it is impossible to use this color model. The problem is that to get CMY model working correctly, you should use ideally pure, unadulterated inks. However it is almost impossible to create such clean colorants (at least at a reasonable cost). But if we use impure ink, we cannot get the proper result. For example if we mix all three inks, we will get dirty brown color instead of black.

The problem was resolved by adding a black component to the CMY triple. This modified color model is called CMYK (K means blacK; last letter instead of the first was taken as B could be mixed up with Blue). It allows printing pure black color (and it is cheaper than using three colors) and this model is widely used in practice. However using four components instead of three yields some problems. As the most images are stored in RGB color model, we need to convert them to CMYK before printing. Converting from RGB to CMY was very easy - you only had to invert pixels. Getting CMYK image is much harder. A special technique needs to be used.

HSL Model

Color models which are presented as a sum of some primary colors are not always convenient to use. These models are not intuitive. Non-professionals can hardly understand what RGB or CMYK channels to change to make a color brighter or to change a tint. That's why other color models were proposed. Instead of intensities of primary colors, each pixel is represented as set of some color characteristics. An example of such a model is HSL - each pixel contains Hue, Saturation and Lightness.

Hue specifies the tint of the color. In the HSL model, hue is represented as an angle on the color wheel (see figure below). 0 degrees is considered as the red color, 120 degrees is the green color and 180 degrees is the blue color. Antipode points on the wheel (colors which are placed at the opposite points of the wheel) are called complementary colors. Note that the primary colors of RGB model are complementary to the primary colors of CMY.

Saturation is the "depth" or "purity" of the color. Low-saturated colors are close to gray, high saturated are close to the primary color. On the color wheel, saturation is specified as a distance from the center of the wheel.

Lightness is the intensity of the color. Low lightness specifies that color is dark, close to black. High lightness specifies that color is close to white. Note, too high or too low values of lightness reduce maximum saturation (black or white color cannot be close to any primary color).

This color model may seem to be device independent, but it is not actually so. From the mathematical point of view, it is just another representation of the RGB color model. That's why images are never stored using this color model. However this model is often used during image processing. In particular, Graphics Mill allows you to adjust hue, saturation and lightness of the image (using AdjustHsl transform).

Lab Model

Lab model is a complex color model that allows for representing a wide color gamut. Lab model is device independent and its gamut includes both the RGB and CMYK gamuts, so it is extremely useful as intermediate format for conversion between RGB and CMYK color spaces. In Lab each color is represented with its coordinates in the three-axis system. The first axis is Lightness, and the other two, a and b, are color axes.

Lightness axis goes from black to white and all shades of grey lay exactly on this axis.

a axis goes from green to magenta, where negative values are green, and positive ones are magenta.

b axis goes from blue to yellow, where negative values are blue, and positive ones are yellow.

Lab model

Grayscale Model

There exists a special color model. It has the single channel with stores only pixel luminosity, and therefore it has no chrominance components (i.e. color information). Grayscale images typically have a special application, e.g. in medical imaging.

See also

Manual