Color Models in Computer Graphics



In graphics, we generate color images there are multiple such modes available. Read this chapter to learn the various color models used in computer graphics. We will cover the basics and provide examples to help you understand these concepts better.

Key Characteristics of Color Models

Color is how we perceive light reflected from objects. Our eyes detect color in the visible range of the electromagnetic spectrum. This range is in between 390 to 700 nanometers (nm).

Color has three main characteristics

  • Hue − This is the dominant wavelength of light we perceive. It is what we typically mean when we name a color like "red" or "blue".
  • Saturation − This refers to the purity of the color. A highly saturated color is vivid, while a less saturated color appears more muted.
  • Luminance − This is the lightness or intensity of the color. It determines how bright or dark a color appears.
Color Models in Computer Graphics

Hue and saturation together are called the chroma components of color. Luminance is referred to as the luma component.

Color Models in Computer Graphics

Color models use primary colors to produce a wide range of other colors. The range of colors a model can produce is called its color gamut. Let us explore some popular color models used in computer graphics.

RGB Color Model

The RGB color model is the most widely used in computer graphics. It uses three primary colors: Red, Green, and Blue. Let us see some of the key features of the RGB model. It is represented by a unit cube:

  • Values for R, G, and B range from 0 to 1
  • Black is at the origin (0,0,0) and White is at (1,1,1)
  • The diagonal line from Black to White is called the Gray Line
RGB Color Model

Examples in the RGB model:

  • Pure Red: (1,0,0)
  • Pure Green: (0,1,0)
  • Pure Blue: (0,0,1)
  • Yellow: (1,1,0)
  • Magenta: (1,0,1)
  • Cyan: (0,1,1)

The RGB model is used in display devices like computer monitors and TVs. It uses additive color mixing to produce colors. This means it starts with black and adds light to create other colors.

CMY Color Model

The CMY model uses Cyan, Magenta, and Yellow as its primary colors. It's also represented by a unit cube:

  • White is at the origin (0,0,0) and Black is at (1,1,1)
  • It uses subtractive color mixing

Examples in the CMY model −

  • Pure Cyan: (1,0,0)
  • Pure Magenta: (0,1,0)
  • Pure Yellow: (0,0,1)
  • Red: (0,1,1)
  • Green: (1,0,1)
  • Blue: (1,1,0)

The CMY model is primarily used in printing. It is often extended to CMYK, where K stands for Black. This is because combining pure cyan, magenta, and yellow does not produce a true black in practice.

YUV/YIQ/YCbCr Color Model

This family of color models separates luminance (brightness) from chrominance (color information). The key features are −

  • Y represents luminance
  • U and V (or I and Q) represent color information

It is widely used in television broadcasting and video compression

Example of RGB to YIQ conversion −

  • Y = 0.299R + 0.587G + 0.114B
  • I = 0.596R - 0.275G - 0.321B
  • Q = 0.212R - 0.523G + 0.311B

This model is efficient for transmission because it separates the brightness signal (Y) from the color information.

HSV Color Model

The HSV model represents colors using Hue, Saturation, and Value. The key features of the HSV model is it is represented by a hexagonal cone as shown in the above figure.

  • Hue is measured as an angle (0-360°)
  • Saturation and Value range from 0 to 1

It's useful for intuitive color selection

Examples in the HSV model −

  • Red: H = 0°, S = 1, V = 1
  • Green: H = 120°, S = 1, V = 1
  • Blue: H = 240°, S = 1, V = 1
  • Yellow: H = 60°, S = 1, V = 1

HLS Color Model

The HLS model is similar to HSV but uses Lightness instead of Value. The key features of the HLS model:

  • It's represented by a double hexagonal cone
  • Hue is measured as an angle (0-360°)
  • Saturation and Lightness range from 0 to 1
  • Pure colors are at L = 0.5

Examples in the HLS model −

  • Red: H = 0°, S = 1, L = 0.5
  • Green: H = 120°, S = 1, L = 0.5
  • Blue: H = 240°, S = 1, L = 0.5
  • White: H = any, S = 0, L = 1
  • Black: H = any, S = 0, L = 0

The HLS model is also used in color selection interfaces and image processing tasks.

Example of Converting between Color Models

Converting between color models is often necessary in graphics applications. Here is a simple example of converting from RGB to HSV.

Find the maximum (max) and minimum (min) of R, G, and B −

  • V = max
  • S = (max - min) / max (if max is not zero)
  • H is calculated based on which color is max −
    • If R is max: H = (G - B) / (max - min)
    • If G is max: H = 2 + (B - R) / (max - min)
    • If B is max: H = 4 + (R - G) / (max - min)
  • Multiply H by 60 to convert to degrees
  • Applications of Color Models

Different color models are used for various applications in computer graphics −

  • RGB − Used in display devices like monitors, TVs, and digital cameras
  • CMY/CMYK − Used in printing and publishing
  • YUV/YIQ − Used in television broadcasting and video compression
  • HSV/HLS − Used in color selection interfaces and image processing tasks

Conclusion

In this chapter, we covered the basic concepts of color models in computer graphics. We explained the basics of color perception and examined various color models including RGB, CMY, YUV, HSV, and HLS. Finally, we explained how to convert between different color models and their applications in different areas of computer graphics.

Advertisements