Image Processing Toolbox User's Guide Previous page   Next Page

Converting Between Device-Independent Color Spaces

The standard terms used to describe colors, such as hue, brightness, and intensity, are subjective and make comparisons difficult.

In 1931, the International Commission on Illumination, known by the acronym CIE, for Commission Internationale de l'Éclairage, studied human color perception and developed a standard, called the CIE XYZ. This standard defined a three-dimensional space where three values, called tristimulus values, define a color. This standard is still widely used today.

In the decades since that initial specification, the CIE has developed several additional color space specifications that attempt to provide alternative color representations that are better suited to some purposes than XYZ. For example, in 1976, in an effort to get a perceptually uniform color space that could be correlated with the visual appearance of colors, the CIE created the L*a*b* color space.

The toolbox supports conversions between members of the CIE family of device-independent color spaces. In addition, the toolbox also supports conversions between these CIE color spaces and the sRGB color space. This color space was defined by an industry group to describe the characteristics of a typical PC monitor.

This section

Supported Conversions

This table lists all the device-independent color spaces that the toolbox supports.

Color Space
Description
Supported Conversions

The original, 1931 CIE color space specification.
, , , and

CIE specification that provides normalized chromaticity values. The capital Y value represents luminance and is the same as in XYZ.


CIE specification that attempts to make the chromaticity plane more visually uniform. is luminance and is the same as Y in XYZ.


CIE specification in which u and v are rescaled to improve uniformity.


CIE specification that attempts to make the luminance scale more perceptually uniform. is a nonlinear scaling of L, normalized to a reference white point.


CIE specification where c is chroma and h is hue. These values are a polar coordinate conversion of a* and b* in .


Standard adopted by major manufacturers that characterizes the average PC monitor.
and

Example: Performing a Color Space Conversion

To illustrate a conversion between two device-independent color spaces, this example reads an RGB color image into the MATLAB workspace and converts the color data to the XYZ color space:

  1. Import color space data. This example reads an RGB color image into the MATLAB workspace.
  2. Create a color transformation structure. A color transformation structure defines the conversion between two color spaces. You use the makecform function to create the structure, specifying a transformation type string as an argument.
  1. This example creates a color transformation structure that defines a conversion from RGB color data to XYZ color data.

  1. Perform the conversion. You use the applycform function to perform the conversion, specifying as arguments the color data you want to convert and the color transformation structure that defines the conversion. The applycform function returns the converted data.

Color Space Data Encodings

When you convert between two device-independent color spaces, the data type used to encode the color data can sometimes change, depending on what encodings the color spaces support. In the preceding example, the original image is uint8 data. The XYZ conversion is uint16 data. The XYZ color space does not define a uint8 encoding. The following table lists the data types that can be used to represent values in all the device-independent color spaces.

Color Space
Encodings
XYZ
uint16 or double
xyY
double
uvL
double
u'v'L
double
L*a*b*
uint8, uint16, or double
L*ch
double
sRGB
double

As the table indicates, certain color spaces have data type limitations. For example, the XYZ color space does not define a uint8 encoding. If you convert 8-bit CIE LAB data into the XYZ color space, the data is returned in uint16 format. If you want the returned XYZ data to be in the same format as the input LAB data, you can use one of the following toolbox color space format conversion functions.


Previous page  Converting Color Data Between Color Spaces Performing Profile-Based Conversions Next page

© 1994-2005 The MathWorks, Inc.