Image Processing Toolbox User's Guide Previous page   Next Page

Performing Profile-Based Conversions

The Image Processing Toolbox can perform color space conversions based on device profiles. This section includes the following topics:

Understanding Device Profiles

If two colors have the same CIE colorimetry, they will match if viewed under the same conditions. However, because color images are typically produced for a wide variety of viewing environments, it is necessary to go beyond simple application of the CIE system.

For this reason, the International Color Consortium (ICC) has defined a Color Management System (CMS) that provides a means for communicating color information among input, output, and display devices. The CMS uses device profiles that contain color information specific to a particular device. Vendors that support CMS provide profiles that characterize the color reproduction of their devices, and methods, called Color Management Modules (CMM), that interpret the contents of each profile and perform the necessary image processing.

Device profiles contain the information that color management systems need to translate color data between devices. Any conversion between color spaces is a mathematical transformation from some domain space to a range space. With profile-based conversions, the domain space is often called the source space and the range space is called the destination space. In the ICC color management model, profiles are used to represent the source and destination spaces.

For more information about color management systems, go to the International Color Consortium Web site, www.color.org.

Reading ICC Profiles

To read an ICC profile into the MATLAB workspace, use the iccread function. In this example, the function reads in the profile for the color space that describes color monitors.

iccread returns the contents of the profile in the structure P. All profiles contain a header, a tag table, and a series of tagged elements. The header contains general information about the profile, such as the device class, the device color space, and the file size. The tagged elements, or tags, are the data constructs that contain the information used by the CMM. For more information about the contents of a profile, see the iccread function reference page.

Using iccread, you can read both Version 2 (ICC.1:2001-04) or Version 4 (ICC.1:2001-12) ICC profile formats. For detailed information about these specifications and their differences, visit the ICC web site, www.color.org.

Writing Profile Information to a File

To export ICC profile information from the MATLAB workspace to a file, use the iccwrite function. This example reads a profile into the MATLAB workspace and then writes the profile information out to a new file.

iccwrite returns the profile it writes to the file in P_new because it can be different than the input profile P. For example, iccwrite updates the Filename field in P to match the name of the file specified as the second argument.

iccwrite checks the validity of the input profile structure. If any required fields are missing, iccwrite errors. To determine if a structure is a valid ICC profile, use the isicc function.

Using iccwrite, you can export profile information in both Version 2 (ICC.1:2001-04) or Version 4 (ICC.1:2001-12) ICC profile formats. The value of the Version field in the file profile header determines the format version. For detailed information about these specifications and their differences, visit the ICC web site, www.color.org.

Example: Performing a Profile-Based Conversion

To illustrate a profile-based color space conversion, this section presents an example that converts color data from the RGB space of a monitor to the CMYK space of a printer. This conversion requires two profiles: a monitor profile and a printer profile. The source color space in this example is monitor RGB and the destination color space is printer CMYK:

  1. Import RGB color space data. This example imports an RGB color image into the MATLAB workspace.
  2. Read ICC profiles. Read the source and destination profiles into the MATLAB workspace. This example uses the sRGB profile as the source profile. The sRGB profile is an industry-standard color space that describes a color monitor.
  1. For the destination profile, the example uses a profile that describes a particular color printer. The printer vendor supplies this profile. (The following profile and several other useful profiles can be obtained as downloads from www.adobe.com.)

  1. Create a color transformation structure. You must create a color transformation structure to define the conversion between the color spaces in the profiles. 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 CMYK 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 function returns the converted data.
  2. Write the converted data to a file. To export the CMYK data, use the imwrite function, specifying the format as TIFF. If the format is TIFF and the data is an m-by-n-by-4 array, imwrite writes CMYK data to the file.
  1. To verify that the CMYK data was written to the file, use imfinfo to get information about the file and look at the PhotometricInterpretation field.

Specifying the Rendering Intent

For most devices, the range of reproducible colors is much smaller than the range of colors represented by the PCS. It is for this reason that four rendering intents (or gamut mapping techniques) are defined in the profile format. Each one has distinct aesthetic and color-accuracy tradeoffs.

When you create a profile-based color transformation structure, you can specify the rendering intent for the source as well as the destination profiles. For more information, see the makecform reference information.


Previous page  Converting Between Device-Independent Color Spaces Converting Between Device-Dependent Color Spaces Next page

© 1994-2005 The MathWorks, Inc.