applycform

Apply device-independent color space transformation

Syntax

B = applycform(A,C)

Description

B = applycform(A,C) converts the color values in A to the color space specified in the color transformation structure C. The color transformation structure specifies various parameters of the transformation. See makecform for details.

If A is two-dimensional, each row is interpreted as a color unless the color transformation structure contains a grayscale ICC profile. (See Note for this case.) A can have 1 or more columns, depending on the input color space. B has the same number of rows and 1 or more columns, depending on the output color space. (The ICC spec currently supports up to 15-channel device spaces.)

If A is three-dimensional, each row-column location is interpreted as a color, and size(A,3) is typically 1 or more, depending on the input color space. B has the same number of rows and columns as A, and size(B,3) is 1 or more, depending on the output color space.

Class Support

A is a real, nonsparse array of class uint8, uint16, or double or a string. A is only a string if C was created with the following syntax:

C = makecform('named', profile, space)

The output array B has the same class as A, unless the output space is XYZ. If the input is XYZ data of class uint8, the output is of class uint16, because there is no standard 8-bit encoding defined for XYZ color values.

    Note:   If the color transformation structure C contains a grayscale ICC profile, applycform interprets each pixel in A as a color. A can have any number of columns. B has the same size as A.

Examples

Read in a color image that uses the sRGB color space.

rgb = imread('peppers.png');

Create a color transformation structure that defines an sRGB to L*a*b* conversion.

C = makecform('srgb2lab');

Perform the transformation with applycform.

lab = applycform(rgb,C);
Was this topic helpful?