10.3 设备颜色空间之间的转换¶
Conversions among Device Colour Spaces
10.3.1 概述¶
General
每种光栅输出设备都有一个本机颜色空间,通常是标准设备颜色空间之一(DeviceGray、DeviceRGB或DeviceCMYK)。换句话说,大多数设备支持按照灰度(单色)、RGB(红-绿-蓝)或CMYK(青-品红-黄-黑)模型进行颜色再现。如果设备支持连续色调输出,则应直接进行再现。否则,应通过半色调(halftoning)实现。
设备的本机颜色空间也称为其工艺颜色模型(process colour model)。工艺颜色是通过一种或多种标准工艺着色剂(process colorants)组合生成的颜色。任何设备颜色空间或基于CIE的颜色空间中指定的颜色都应以工艺颜色的形式进行渲染。某些设备还可能支持额外的专色着色剂(spot colorants),但它们只能通过Separation或DeviceN颜色空间进行绘制。这些专色着色剂不应参与设备或基于CIE的颜色空间的渲染,也不应受到注释中描述的转换过程的影响。
注意
一些设备提供的本机颜色空间不同于前述三种颜色空间,而是由不同的着色剂组合构成。在这种情况下,符合标准的阅读器可自行决定如何将标准设备颜色空间转换为设备的本机颜色空间。
在了解设备的本机颜色空间及其他输出能力后,符合标准的阅读器应自动将文件中指定的颜色值转换为适合设备本机颜色空间的颜色值。如果文件直接在设备的本机颜色空间中指定颜色,则不应执行转换。
示例
如果文件在DeviceRGB颜色空间中指定了颜色,但设备仅支持灰度(如单色显示器)或CMYK(如彩色打印机),符合标准的阅读器应执行必要的转换。
用于设备颜色空间之间转换的算法非常简单。从人类观察者的角度来看,这些转换只能粗略地逼近原始颜色。要实现更精细的颜色转换控制,可以使用基于CIE的颜色规范和渲染。此外,设备颜色空间还可以重新映射到基于CIE的颜色空间(参见8.6.5.6“默认颜色空间”)。
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 CIE- based 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").
10.3.2 DeviceGray 与 DeviceRGB 之间的转换¶
Conversion between DeviceGray and DeviceRGB
黑色、白色和介于两者之间的灰色可以视为RGB颜色的特殊情况。灰度值应由单个数值描述:0.0 表示黑色,1.0 表示白色,中间值表示不同的灰度级别。
灰度级应等同于所有三个分量相同的RGB值。换句话说,与特定灰度值等效的RGB颜色值应为:
对于给定的RGB值,灰度值应按照NTSC视频标准计算,该标准确定了彩色电视信号在黑白电视机上的渲染方式:
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
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:
10.3.3 DeviceGray 与 DeviceCMYK 之间的转换¶
Conversion between DeviceGray and DeviceCMYK
在名义上,灰度级是 CMYK 颜色模型中黑色分量的补数。因此,与特定灰度级等效的 CMYK 颜色值应为:
要获取给定 CMYK 值的等效灰度级,应考虑所有分量的贡献:
黑色分量与其他三个分量之间的相互作用在 10.3.4 中有更详细的说明。
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
To obtain the equivalent gray level for a given CMYK value, the contributions of all components shall be taken into account:
The interactions between the black component and the other three are elaborated in 10.3.4.
10.3.4 从 DeviceRGB 到 DeviceCMYK 的转换¶
Conversion from DeviceRGB to DeviceCMYK
颜色值从 RGB 转换为 CMYK 是一个两步过程。第一步是将红-绿-蓝 (RGB) 颜色值转换为对应的青色 (cyan)、品红 (magenta) 和黄色 (yellow) 分量。第二步是生成黑色 (black) 分量,并调整其他分量,以更好地逼近原始颜色。
注释 1
减色法的基本颜色青色 (cyan)、品红 (magenta) 和黄色 (yellow) 是加色法基本颜色红色 (red)、绿色 (green) 和蓝色 (blue) 的补色。
示例
青色油墨会吸收白光中的红色分量。理论上,转换过程非常简单:
例如,颜色值 (0.2, 0.7, 0.4)(红、绿、蓝)可转换为:
注释 2
从逻辑上讲,仅使用青色、品红和黄色即可生成印刷颜色。当青色、品红和黄色的比例相同时,理论上应产生等量的黑色。然而,在实际应用中,彩色印刷油墨的混合并不完美,这些组合通常会形成深棕色,而非纯黑色。为了在打印机上获得更准确的颜色再现,通常使用真正的黑色油墨替代部分混合黑色。大多数彩色打印机支持黑色分量(即 CMYK 颜色模型中的 K 分量)。计算该分量的数量需要额外的步骤:
- 黑色生成(Black Generation, BG):计算在再现特定颜色时应使用的黑色量。
- 底色去除(Undercolor Removal, UCR):减少青色、品红和黄色分量的量,以补偿黑色生成所增加的黑色量。
从 RGB 到 CMYK 的完整转换过程如下,其中 BG(k) 和 UCR(k) 分别表示黑色生成和底色去除函数的调用:
黑色生成和底色去除函数应定义为 PDF 函数字典(参见 7.10,"函数"),并作为图形状态中的参数。它们应作为图形状态参数字典中 BG 和 UCR(或 BG2 和 UCR2)条目的值进行指定(参见 [表 58])。每个函数应使用单个数值作为输入,并返回单个数值作为结果。
黑色生成和底色去除函数的输入应为 k,即通过从 1.0 中减去原始 RGB 颜色值后计算出的中间 c、m 和 y 值的最小值。
注释 3
在名义上,k 代表可以从青色、品红和黄色分量中去除,并替换为独立黑色分量的量。
黑色生成函数应根据 k 计算黑色分量。它可以直接返回 k,也可以返回比 k 更大的值(增加黑色量)、更小的值(减少黑色量)或 0.0(不使用黑色)。
底色去除函数应计算从中间 c、m 和 y 分量中去除的量,以生成最终的青色、品红和黄色分量。它可以直接返回 k,也可以返回 0.0(不去除颜色)、黑色量的某个比例,甚至一个负值,从而增加总色料量。
应用黑色生成和底色去除后得到的最终颜色分量值应在 0.0 到 1.0 之间。如果某个值超出该范围,应自动替换为最接近的有效值,而不会产生错误提示。
注释 4
这种替换在上述公式中通过 min 和 max 操作显式表示。
正确选择黑色生成和底色去除函数取决于输出设备的特性。每个设备应配置适用于其自身的默认值。
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:
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:
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.
10.3.5 从 DeviceCMYK 到 DeviceRGB 的转换¶
Conversion from DeviceCMYK to DeviceRGB
从 CMYK 到 RGB 的颜色值转换是一个简单的操作,不涉及黑色生成或底色去除:
黑色分量应添加到每个其他颜色分量中,然后通过从 1.0 中减去它们来转换为相应的补色。
Conversion of a colour value from CMYK to RGB is a simple operation that does not involve black generation or undercolour removal:
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.