This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

makecform

Create color transformation structure

The makecform function supports conversions between members of the family of device-independent color spaces defined by the Commission Internationale de l'Éclairage (International Commission on Illumination, or CIE). makecform also supports conversions to and from the sRGB and CMYK color spaces. To perform a color space transformation, pass the color transformation structure created by makecform as an argument to the applycform function.

Syntax

C = makecform(type)
C = makecform(type,'WhitePoint',WP)
C = makecform(type,'AdaptedWhitePoint',WP)
C = makecform('adapt','WhiteStart',WPS,'WhiteEnd',WPE,'AdaptModel',model)
C = makecform('srgb2cmyk','RenderingIntent',intent)
C = makecform('cmyk2srgb','RenderingIntent',intent)
C = makecform('icc',src_profile,dest_profile)
C = makecform('icc',src_profile,dest_profile,'SourceRenderingIntent',src_intent,'DestRenderingIntent',dest_intent)
C = makecform('mattrc',MatTRC,'Direction',direction)
C = makecform('mattrc',profile,'Direction',direction)
C = makecform('mattrc',profile,'Direction',direction,'RenderingIntent',trc_intent)
C = makecform('graytrc',profile,'Direction',direction)
C = makecform('graytrc',profile,'Direction',direction,'RenderingIntent',trc_intent)
C = makecform('clut',profile,LUTtype)
C = makecform('named',profile,space)

Description

example

C = makecform(type) creates a color transformation structure C that defines the color space conversion specified by type.

C = makecform(type,'WhitePoint',WP) specifies the value of the reference white point, WP, for 'xyz2lab' or 'lab2xyz' conversions.

C = makecform(type,'AdaptedWhitePoint',WP) specifies the adapted white point, WP, for 'srgb2lab', 'lab2srgb', 'srgb2xyz', or 'xyz2srgb' conversions.

C = makecform('adapt','WhiteStart',WPS,'WhiteEnd',WPE,'AdaptModel',model) creates a linear chromatic-adaptation color transformation using the chromatic-adaptation model, model, starting with whitepoint WPS and ending with whitepoint WPE.

C = makecform('srgb2cmyk','RenderingIntent',intent) and

C = makecform('cmyk2srgb','RenderingIntent',intent) specify the rendering intent for color transformations between sRGB IEC61966-2.1 and "Specifications for Web Offset Publications" (SWOP) CMYK.

C = makecform('icc',src_profile,dest_profile) creates a color transformation based on two ICC profiles, src_profile and dest_profile.

C = makecform('icc',src_profile,dest_profile,'SourceRenderingIntent',src_intent,'DestRenderingIntent',dest_intent) creates a color transformation based on two ICC color profiles, src_profile and dest_profile, specifying the rendering intent for the source and destination profiles.

example

C = makecform('mattrc',MatTRC,'Direction',direction) creates a color transformation based on a Matrix/Tone Reproduction Curve (MatTRC) model, in either the forward or inverse direction.

C = makecform('mattrc',profile,'Direction',direction) creates a color transformation based on the 'MatTRC' field of the ICC color profile profile, in either the forward or inverse direction.

C = makecform('mattrc',profile,'Direction',direction,'RenderingIntent',trc_intent) adds the option of specifying the rendering intent.

C = makecform('graytrc',profile,'Direction',direction) creates a monochrome transformation based on a single-channel Tone Reproduction Curve (GrayTRC) contained in an ICC color profile.

C = makecform('graytrc',profile,'Direction',direction,'RenderingIntent',trc_intent) adds the option of specifying the rendering intent.

C = makecform('clut',profile,LUTtype) creates a color transformation based on a color lookup table of the type LUTtype, contained in an ICC color profile, profile.

C = makecform('named',profile,space) creates a color transformation from a named color profile (with a 'NamedColor2' field) to coordinates in the color space space.

Examples

Convert sRGB Image to L*a*b*

Convert RGB image to L*a*b*, assuming input image is sRGB.

rgb = imread('peppers.png');
cform = makecform('srgb2lab');
lab = applycform(rgb,cform);

Convert RGB to XYZ

Convert from a non-standard RGB color profile to the device-independent XYZ profile connection space. Note that the ICC input profile must include a MatTRC value.

InputProfile = iccread('myRGB.icc');
C = makecform('mattrc',InputProfile.MatTRC, ...
              'direction','forward');

Input Arguments

collapse all

Color space conversion type, specified as one of the following character vectors. For a list of the abbreviations used by the Image Processing Toolbox™ software for each color space, see Definitions.

Type

Description

'cmyk2srgb'

Convert from the CMYK color space to the sRGB color space.

'lab2lch'

Convert from the L*a*b* to the L*ch color space.

'lab2srgb'

Use lab2rgb instead.

'lab2xyz'

Use lab2xyz instead.

'lch2lab'

Convert from the L*ch to the L*a*b* color space.

'srgb2cmyk'

Convert from the sRGB to the CMYK color space.

'srgb2lab'

Use rgb2lab instead.

'srgb2xyz'

Use rgb2xyz instead.

'upvpl2xyz'

Convert from the uvL to the XYZ color space.

'uvl2xyz'

Convert from the uvL to the XYZ color space.

'xyl2xyz'

Convert from the xyY to the XYZ color space.

'xyz2lab'

Use xyz2lab instead.

'xyz2srgb'

Use xyz2rgb instead.

'xyz2upvpl'

Convert from the XYZ to the uvL color space.

'xyz2uvl'

Convert from the XYZ to the uvL color space.

'xyz2xyl'

Convert from the XYZ to the xyY color space.

Data Types: char | string

Reference or adapted white point, specified as a 1-by-3 numeric vector of XYZ values, scaled so that Y = 1. Use the whitepoint function to create the WP vector. The default white point is the vector returned by whitepoint('ICC').

To get an adaptive whitepoint value that is consistent with some published sRGB equations, set the value of WP to [0.9504, 1.0000, 1.0888], which is the vector returned by whitepoint('D65').

Starting or ending white point used for a linear chromatic-adaptation transform, specified as a 1-by-3 numeric vector of XYZ values, scaled so that Y = 1. Use the whitepoint function to create the WPS or WPE vector.

Rendering intent, specified as 'Perceptual', 'AbsoluteColorimetric', 'RelativeColorimetric', or 'Saturation'.

Rendering intents specify the style of reproduction that should be used when these profiles are combined. For most devices, the range of reproducible colors is much smaller than the range of colors represented by the PCS. Rendering intents define gamut mapping techniques. Each rendering intent has distinct aesthetic and color-accuracy trade-offs.

Value

Description

'AbsoluteColorimetric'

Maps all out-of-gamut colors to the nearest gamut surface while maintaining the relationship of all in-gamut colors. This absolute rendering contains color data that is relative to a perfectly reflecting diffuser.

'Perceptual' (default)

Employs vendor-specific gamut mapping techniques for optimizing the range of producible colors of a given device. The objective is to provide the most aesthetically pleasing result even though the relationship of the in-gamut colors might not be maintained. This media-relative rendering contains color data that is relative to the device's white point.

'RelativeColorimetric'

Maps all out-of-gamut colors to the nearest gamut surface while maintaining the relationship of all in-gamut colors. This media-relative rendering contains color data that is relative to the device's white point.

'Saturation'

Employs vendor-specific gamut mapping techniques for maximizing the saturation of device colors. This rendering is generally used for simple business graphics such as bar graphs and pie charts. This media-relative rendering contains color data that is relative to the device's white point.

Source or destination rendering intent for a color transformation between two ICC profiles, specified as 'Perceptual', 'AbsoluteColorimetric', 'RelativeColorimetric', or 'Saturation'. For more information, see intent.

Rendering intent for tone reproduction curve (MatTRC or grayTRC), specified as 'RelativeColorimetric' or 'AbsoluteColorimetric'. When 'AbsoluteColorimetric' is specified, the colorimetry is referenced to a perfect diffuser, rather than to the media white point of the ICC color profile, profile. For more information, see intent.

Chromatic-adaptation model used to create a linear chromatic-adaptation transform, specified as 'Bradford' or 'vonKries'.

ICC color profile, specified as a structure as returned by iccread. If profile is a named color profile, it must have a NamedColor2 field.

Source or destination ICC color profile, specified as a structure as returned by iccread.

Matrix/tone reproduction curve model, specified as a structure. MatTRC is typically obtained from the 'MatTRC' field of an ICC profile structure returned by iccread, based on tags contained in an ICC color profile. The MatTRC model contains an RGB-to-XYZ matrix and RGB tone reproduction curves.

Direction to apply the tone reproduction curve model, specified as 'forward' or 'inverse'.

  • For a multi-channel tone reproduction curve ('mattrc'), 'forward' applies the model in the RGB to XYZ direction, and 'inverse' applies the model in the XYZ to RGB direction. For more information, see section 6.3.1.2 of the International Color Consortium specification ICC.1:2001-04 or ICC.1:2001-12, available at www.color.org.

  • For a single-channel tone reproduction curve ('graytrc'), 'forward' applies the model in the device to PCS direction, and 'inverse' applies the model in the PCS to device direction. "Device" here refers to the grayscale signal communicating with the monochrome device. "PCS" is the Profile Connection Space of the ICC profile and can be either XYZ or L*a*b*, depending on the 'ConnectionSpace' field in profile.Header.

Lookup table type, specified as one of the following values. LUTtype specifies which 'clut' in the profile structure is to be used. Each LUTtype listed in the table below contains the components of an 8-bit or 16-bit LUTtag that performs a transformation between device colors and PCS colors using a particular rendering. For more information about 'clut' transformations, see Section 6.5.7 of the International Color Consortium specification ICC.1:2001-04 (Version 2) or Section 6.5.9 of ICC.1:2001-12 (Version 4), available at http://www.color.org.

LUT Type

Description

'AToB0' (default)

Device to PCS: perceptual rendering intent

'AToB1'

Device to PCS: media-relative colorimetric rendering intent

'AToB2'

Device to PCS: saturation rendering intent

'AToB3'

Device to PCS: ICC-absolute rendering intent

'BToA0'

PCS to device: perceptual rendering intent

'BToA1'

PCS to device: media-relative colorimetric rendering intent

'BToA2'

PCS to device: saturation rendering intent

'BToA3'

PCS to device: ICC-absolute rendering intent

'Gamut'

Determines which PCS colors are out of gamut for a given device

'Preview0'

PCS colors to the PCS colors available for soft proofing using the perceptual rendering

'Preview1'

PCS colors available for soft proofing using the media-relative colorimetric rendering.

'Preview2'

PCS colors to the PCS colors available for soft proofing using the saturation rendering.

Color space, specified as 'PCS' or 'Device'. The 'PCS' option is always available and will return L*a*b* or XYZ coordinates, depending on the 'ConnectionSpace' field in profile.Header. The 'Device' option, when active, returns device coordinates, the dimension depending on the 'ColorSpace' field in profile.Header. Coordinates are always returned in 'double' format.

Output Arguments

collapse all

Color transformation structure, returned as a struct.

More About

collapse all

Color Space Abbreviations

The Image Processing Toolbox software uses the following abbreviations to represent color spaces.

Abbreviation

Description

xyz

1931 CIE XYZ tristimulus values (2° observer)

xyl

1931 CIE xyY chromaticity values (2° observer), where x and y refer to the xy-coordinates of the associated CIE chromaticity diagram, and l refers to Y (luminance).

uvl

1960 CIE uvY values, where u and v refer to the uv-coordinates, and l refers to Y (luminance).

upvpl

1976 CIE uvY values, where up and vp refer to the uv′-coordinates and l refers to Y (luminance).

lab

1976 CIE L*a*b* values. Note that l refers to L* (CIE 1976 psychometric lightness) rather than luminance (Y).

lch

Polar transformation of CIE L*a*b* values, where c = chroma and h = hue

cmyk

Standard values used by printers

srgb

Standard computer monitor RGB values, (IEC 61966-2-1)

Introduced before R2006a