Repository navigation
PDF Spec 10 Color Conversions
Part of: PDF-Spec-10-Rendering
Navigation: PDF-Spec-10-General | PDF-Spec-Index | PDF-Spec-10-Halftones
Each raster output device has a native colour space , which typically is one of the standard device colour spaces ( DeviceGray , DeviceRGB , or DeviceCMYK ). In other words, most devices support reproduction of colours according to a grayscale (monochrome), RGB (red-green-blue), or CMYK (cyan-magenta-yellow-black) model. If the device supports continuous-tone output, reproduction shall occur directly. Otherwise, it shall be accomplished by means of halftoning.
A device's native colour space is also called its process colour model . Process colours are ones that are produced by combinations of one or more standard process colorants . Colours specified in any device or CIEbased colour space shall be rendered as process colours. A device may also support additional spot colorants , which shall be painted only by means of Separation or DeviceN colour spaces. They shall not be involved in the rendering of device or CIE-based colour spaces, nor shall they be subject to the conversions described in the Note.
NOTE
Some devices provide a native colour space that is not one of the three named previously but consists of a different combination of colorants. In that case, conversion from the standard device colour spaces to the device's native colour space may be performed by the conforming reader in a manner of its own choosing.
Knowing the native colour space and other output capabilities of the device, the conforming reader shall automatically convert the colour values specified in a file to those appropriate for the device's native colour space. If the file specifies colours directly in the device's native colour space, no conversions shall be performed.
EXAMPLE
If a file specifies colours in the DeviceRGB colour space but the device supports grayscale (such as a monochrome display) or CMYK (such as a colour printer), the conforming reader shall perform the necessary conversions.
The algorithms used to convert among device colour spaces are very simple. As perceived by a human viewer, these conversions produce only crude approximations of the original colours. More sophisticated control over colour conversion may be achieved by means of CIE-based colour specification and rendering. Additionally, device colour spaces may be remapped into CIE-based colour spaces (see 8.6.5.6, "Default Colour Spaces").
Black, white, and intermediate shades of gray can be considered special cases of RGB colour. A grayscale value shall be described by a single number: 0.0 corresponds to black, 1.0 to white, and intermediate values to different gray levels.
A gray level shall be equivalent to an RGB value with all three components the same. In other words, the RGB colour value equivalent to a specific gray value shall be
red gray = green gray = blue gray =
The gray value for a given RGB value shall be computed according to the NTSC video standard, which determines how a colour television signal is rendered on a black-and-white television set:
gray 0.3 red × 0.59 green × 0.11 blu × + + =
Nominally, a gray level is the complement of the black component of CMYK . Therefore, the CMYK colour value equivalent to a specific gray level shall be
cyan 0.0 = magenta 0.0 = yellow 0.0 = black 1.0 gray -=
To obtain the equivalent gray level for a given CMYK value, the contributions of all components shall be taken into account:
gray 1.0 min(1.0 · 0.3 cyan × 0.59 magenta × 0.11 yellow × black + + + , -=
The interactions between the black component and the other three are elaborated in 10.3.4.
Conversion of a colour value from RGB to CMYK is a two-step process. The first step shall be to convert the red-green-blue value to equivalent cyan, magenta, and yellow components. The second step shall be to generate a black component and alter the other components to produce a better approximation of the original colour.
- NOTE 1 The subtractive colour primaries cyan, magenta, and yellow are the complements of the additive primaries red, green, and blue.
- EXAMPLE A cyan ink subtracts the red component of white light. In theory, the conversion is very simple:
cyan 1.0 red -=
magenta 1.0 green -=
yellow 1.0 blue -=
A colour that is 0.2 red, 0.7 green, and 0.4 blue can also be expressed as 1.0 -0.2 = 0.8 cyan, 1.0 -0.7 = 0.3 magenta, and 1.0 -0.4 = 0.6 yellow.
- NOTE 2 Logically, only cyan, magenta, and yellow are needed to generate a printing colour. An equal level of cyan, magenta, and yellow should create the equivalent level of black. In practice, however, coloured printing inks do not mix perfectly; such combinations often form dark brown shades instead of true black. To obtain a truer colour rendition on a printer, true black ink is often substituted for the mixed-black portion of a colour. Most colour printers support a black component (the K component of CMYK ). Computing the quantity of this component requires some additional steps:
Black generation calculates the amount of black to be used when trying to reproduce a particular colour.
Undercolor removal reduces the amounts of the cyan, magenta, and yellow components to compensate for the amount of black that was added by black generation.
The complete conversion from RGB to CMYK shall be as follows, where BG ( k ) and UCR ( k ) are invocations of the black-generation and undercolor-removal functions, respectively:
c 1.0 red -= m 1.0 green -= y 1.0 blue -= k min c m y , , ( ) = cyan min 1.0 max 0.0 c UCR k ( ) -, ( ) , ) ( = magenta min 1.0 max 0.0 m UCR k ( ) -, ( ) , ) ( = yellow min 1.0 max 0.0 y UCR k ( ) -, ( ) , ) ( = black min 1.0 max 0.0 BG k ( ) , ( ) , ) ( =
The black-generation and undercolor-removal functions shall be defined as PDF function dictionaries (see 7.10, "Functions") that are parameters in the graphics state. They shall be specified as the values of the BG and UCR (or BG2 and UCR2 ) entries in a graphics state parameter dictionary (see Table 58). Each function shall be called with a single numeric operand and shall return a single numeric result.
The input of both the black-generation and undercolor-removal functions shall be k , the minimum of the intermediate c , m , and y values that have been computed by subtracting the original red , green , and blue components from 1.0.
NOTE 3 Nominally, k is the amount of black that can be removed from the cyan, magenta, and yellow components and substituted as a separate black component.
The black-generation function shall compute the black component as a function of the nominal k value. It may simply return its k operand unchanged, or it may return a larger value for extra black, a smaller value for less black, or 0.0 for no black at all.
The undercolor-removal function shall compute the amount to subtract from each of the intermediate c , m , and y values to produce the final cyan, magenta, and yellow components. It may simply return its k operand unchanged, or it may return 0.0 (so that no colour is removed), some fraction of the black amount, or even a negative amount, thereby adding to the total amount of colorant.
The final component values that result after applying black generation and undercolor removal should be in the range 0.0 to 1.0. If a value falls outside this range, the nearest valid value shall be substituted automatically without error indication.
NOTE 4 This substitution is indicated explicitly by the min and max operations in the preceding formulas.
The correct choice of black-generation and undercolor-removal functions depends on the characteristics of the output device. Each device shall be configured with default values that are appropriate for that device.
- NOTE 5 See 11.7.5, "Rendering Parameters and Transparency" and, in particular, 11.7.5.3, "Rendering Intent and Colour Conversions" for further discussion of the role of black-generation and undercolor-removal functions in the transparent imaging model.
Conversion of a colour value from CMYK to RGB is a simple operation that does not involve black generation or undercolour removal:
red 1.0 min 1.0 cyan black + , ) ( -= green 1.0 min 1.0 magenta black + , ) ( -= blue 1.0 min 1.0 yellow black + , ) ( -=
The black component shall be added to each of the other components, which shall then be converted to their complementary colours by subtracting them each from 1.0.
In the sequence of steps for processing colours, the conforming reader shall apply the transfer function after performing any needed conversions between colour spaces, but before applying a halftone function, if necessary. Each colour component shall have its own separate transfer function; there shall not be interaction between components.
- NOTE 1 Starting with PDF 1.2, a transfer function may be used to adjust the values of colour components to compensate for nonlinear response in an output device and in the human eye. Each component of a device colour space-for example, the red component of the DeviceRGB space-is intended to represent the perceived lightness or intensity of that colour component in proportion to the component's numeric value.
- NOTE 2 Many devices do not actually behave this way, however; the purpose of a transfer function is to compensate for the device's actual behaviour. This operation is sometimes called gamma correction (not to be confused with the CIE-based gamut mapping function performed as part of CIE-based colour rendering).
Transfer functions shall always operate in the native colour space of the output device, regardless of the colour space in which colours were originally specified. (For example, for a CMYK device, the transfer functions apply to the device's cyan, magenta, yellow, and black colour components, even if the colours were originally specified in, for example, a DeviceRGB or CalRGB colour space.) The transfer function shall be called with a numeric operand in the range 0.0 to 1.0 and shall return a number in the same range. The input shall be the value of a colour component in the device's native colour space, either specified directly or produced by conversion from some other colour space. The output shall be the transformed component value to be transmitted to the device (after halftoning, if necessary).
Both the input and the output of a transfer function shall always be interpreted as if the corresponding colour component were additive (red, green, blue, or gray): the greater the numeric value, the lighter the colour. If the component is subtractive (cyan, magenta, yellow, black, or a spot colour), it shall be converted to additive form by subtracting it from 1.0 before it is passed to the transfer function. The output of the function shall always be in additive form and shall be passed on to the halftone function in that form.
Starting with PDF 1.2, transfer functions shall be defined as PDF function objects (see 7.10, "Functions"). There are two ways to specify transfer functions:
- The current transfer function parameter in the graphics state shall consist of either a single transfer function or an array of four separate transfer functions, one each for red, green, blue, and gray or their complements cyan, magenta, yellow, and black. If only a single function is specified, it shall apply to all components. An RGB device shall use the first three, a monochrome device shall use the gray transfer function only, and a CMYK device shall use all four. The current transfer function may be specified as the value of the TR or TR2 entry in a graphics state parameter dictionary; see Table 58.
- The current halftone parameter in the graphics state may specify transfer functions as optional entries in halftone dictionaries (see 10.5.5, "Halftone Dictionaries"). This is the only way to set transfer functions for nonprimary colour components or for any component in devices whose native colour space uses components other than the ones listed previously. A transfer function specified in a halftone dictionary shall override the corresponding one specified by the current transfer function parameter in the graphics state.
In addition to their intended use for gamma correction, transfer functions may be used to produce a variety of special, device-dependent effects. Because transfer functions produce device-dependent effects, a page description that is intended to be device-independent shall not alter them.
When the current colour space is DeviceGray and the output device's native colour space is DeviceCMYK, a conforming reader shall use only the gray transfer function. The normal conversion from DeviceGray to DeviceCMYK produces 0.0 for the cyan, magenta, and yellow components. These components shall not be passed through their respective transfer functions but are rendered directly, producing output containing no coloured inks. This special case exists for compatibility with existing conforming readers that use a transfer function to obtain special effects on monochrome devices, and shall apply only to colours specified in the DeviceGray colour space.
- NOTE 3 See 11.7.5, "Rendering Parameters and Transparency" and, in particular, 11.7.5.2, "Halftone and Transfer Function" for further discussion of the role of transfer functions in the transparent imaging model.
Navigation: PDF-Spec-10-General | PDF-Spec-Index | PDF-Spec-10-Halftones