10.4 传递函数¶
10.4 Transfer Functions
在颜色处理的步骤序列中,符合规范的阅读器应在执行任何必要的颜色空间转换后,但在应用半色调函数(如果需要)之前,应用传递函数。每个颜色分量应有其各自独立的传递函数,分量之间不得相互影响。
注意 1
从 PDF 1.2 开始,传递函数 可用于调整颜色分量的值,以补偿输出设备和人眼的非线性响应。设备颜色空间的每个分量(例如 DeviceRGB 空间中的红色分量)旨在根据该分量的数值表示其感知亮度或强度。
注意 2
然而,许多设备实际上并不按这种方式运行;传递函数的作用是补偿设备的实际行为。这种操作有时称为伽马校正(Gamma 校正),但不应与 CIE- 基于的色域映射函数 混淆,后者是 CIE 颜色渲染的一部分。
无论颜色最初是在何种颜色空间中指定的,传递函数始终应在输出设备的本机颜色空间内运行。(例如,对于 CMYK 设备,传递函数适用于设备的青色、品红色、黄色和黑色分量,即使颜色最初是在 DeviceRGB 或 CalRGB 颜色空间中指定的。)传递函数应以 0.0 到 1.0 之间的数值作为输入,并返回相同范围内的数值。输入应为设备本机颜色空间中的颜色分量值(无论是直接指定的,还是由其他颜色空间转换得到的)。输出则是经过变换的颜色分量值,并将在必要时经过半色调处理后传输到设备。
传递函数的输入和输出始终应被解释为加法颜色模式(即红色、绿色、蓝色或灰色):数值越大,颜色越亮。如果颜色分量为减法颜色模式(即青色、品红色、黄色、黑色或专色),则应在传递给传递函数之前,通过从 1.0 中减去该值来转换为加法模式。函数的输出始终应保持加法模式,并以此形式传递给半色调函数。
从 PDF 1.2 开始,传递函数应定义为 PDF 函数对象(参见 7.10,“函数”)。可以通过以下两种方式指定传递函数:
- 图形状态中的 当前传递函数 参数可以是单个传递函数,也可以是一个由四个独立传递函数组成的数组,分别对应于红色、绿色、蓝色和灰色,或它们的补色(青色、品红色、黄色和黑色)。如果仅指定一个函数,它应适用于所有分量。RGB 设备应使用前三个,单色设备仅使用灰度传递函数,而 CMYK 设备应使用所有四个。当前传递函数可以作为图形状态参数字典中的 TR 或 TR2 条目的值指定;参见 [表 58]。
- 图形状态中的当前半色调参数可以在半色调字典(参见 10.5.5,“半色调字典”)中以可选条目的方式指定传递函数。这是唯一一种可以为非主要颜色分量或本机颜色空间使用非标准分量的设备设置传递函数的方法。半色调字典中指定的传递函数应覆盖图形状态参数字典中 TR 或 TR2 指定的传递函数。
除了用于伽马校正,传递函数还可用于生成各种特殊的、依赖于设备的效果。由于传递函数会导致设备依赖性,因此,旨在保持设备无关性的页面描述不应修改它们。
当当前颜色空间为 DeviceGray,而输出设备的本机颜色空间为 DeviceCMYK 时,符合规范的阅读器应仅使用灰度传递函数。正常情况下,从 DeviceGray 到 DeviceCMYK 的转换会使青色、品红色和黄色分量的值变为 0.0。这些分量不应通过各自的传递函数,而应直接渲染,从而生成不含彩色油墨的输出。此特殊情况是为了兼容那些在单色设备上使用传递函数生成特殊效果的现有阅读器,仅适用于 DeviceGray 颜色空间中指定的颜色。
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.