原文链接:https://poynton.ca/PDFs/Rehabilitation_of_gamma.pdf
标题:The rehabilitation of gamma
作者:查尔斯·波因顿(Charles Poynton)
来源:Reprinted from Rogowitz, B.E., and T.N. Pappas (eds.), Human Vision and Electronic Imaging III, Proceedings of SPIE/IS&T Conference 3299, San Jose, Calif., Jan. 26–30, 1998 (Bellingham, Wash.: SPIE, 1998). © 2002-03-14 Charles Poynton
时间:1998 年
翻译:Horace Lu
术语表(译者注)
- brightness - 视亮度
- luminance - 光亮度
- lightness - 明度
- luma - 非线性视频亮度分量
- transfer function - 转换函数
- intensity - 强度
Abstract 摘要
Gamma characterizes the reproduction of tone scale in an imaging system. Gamma summarizes, in a single numerical parameter, the nonlinear relationship between code value – in an 8-bit system, from 0 through 255 – and luminance. Nearly all image coding systems are nonlinear, and so involve values of gamma different from unity.
伽马描述了成像系统中的色调曲线特性。伽马是一个数值参数,用于概括 8 位系统(8-bit system)中从 0 到 255 的码值与光亮度(luminance)之间的非线性关系。几乎所有图像编码系统都是非线性的,因此它们的伽马值都不是 1。
Owing to poor understanding of tone scale reproduction, and to misconceptions about nonlinear coding, gamma has acquired a terrible reputation in computer graphics and image processing. In addition, the world-wide web suffers from poor reproduction of grayscale and color images, due to poor handling of nonlinear image coding. This paper aims to make gamma respectable again.
由于人们对色调曲线再现(tone scale reproduction)的理解不足,以及对非线性编码(nonlinear coding)存在误解,伽马在计算机图形学和图像处理领域名声不佳。此外,由于非线性图像编码处理不当,万维网上灰度和彩色图像的再现效果也较差。本文旨在为伽马正名。
Gamma’s bad reputation 伽马的坏名声
The left-hand column in this table summarizes the allegations that have led to gamma’s bad reputation. But the reputation is ill-founded – these allegations are false! In the right column, I outline the facts:
左栏总结了导致伽马名声不好的指控。但这些指控是不成立的——它们是错误的!在右栏中,我列出了事实:
Misconception 误解 | Fact 事实 |
---|---|
A CRT’s phosphor has a nonlinear response to beam current. CRT 的荧光粉对电子束电流有非线性响应。 |
The electron gun of a CRT is responsible for its nonlinearity, not the phosphor. CRT 的非线性是由电子枪引起的,而不是荧光粉。 |
The nonlinearity of a CRT monitor is a defect that needs to be corrected. CRT 显示器的非线性是需要纠正的缺陷。 |
The nonlinearity of a CRT is very nearly the inverse of the lightness sensitivity of human vision. The nonlinearity causes a CRT’s response to be roughly perceptually uniform. Far from being a defect, this feature is highly desirable. CRT 的非线性几乎是人类明度敏感度(lightness sensitivity)的反函数,这种非线性使 CRT 的响应大致是感知上均匀的(perceptually uniform)。这不仅不是缺陷,反而是一个非常理想的特性。 |
The main purpose of gamma correction is to compensate for the nonlinearity of the CRT. Gamma 校正的主要目的是补偿 CRT 的非线性。 |
The main purpose of gamma correction in video, desktop graphics, prepress, JPEG, and MPEG is to code luminance or tristimulus values (proportional to intensity) into a perceptually-uniform domain, so as optimize perceptual performance of a limited number of bits in each RGB (or CMYK) component. 在视频、桌面图形、印前处理、JPEG 和 MPEG 中,伽马校正的主要目的是将(与强度成比例的)光亮度或三刺激值编码到感知均匀的域中,以优化每个 RGB(或 CMYK)分量中有限位数的感知性能。 |
Ideally, linear-intensity representations should be used to represent image data. 理想情况下,应该使用线性强度表示法来表示图像数据。 |
If a quantity proportional to intensity represents image data, then 11 bits or more would be necessary in each component to achieve high-quality image reproduction. With nonlinear (gamma-corrected) coding, just 8 bits are sufficient. 如果使用与强度成比例的量来表示图像数据,那么每个分量需要 11 位或更多位,才能实现高质量的图像再现。而使用非线性(经过伽马校正的)编码,只需 8 位就足够了。 |
A CRT is characterized by a power function that relates luminance L to voltage V’: CRT 的特性是光亮度 L 与电压 V’ 之间的幂函数关系: |
CRT 的特性是幂函数关系,但包含一个黑电平偏移项: |
The exponent γ varies anywhere from about 1.4 to 3.5. 指数 |
The exponent itself varies over a rather narrow range, about 2.35 to 2.55. The alleged wide variation comes from variation in offset term of the equation, not the exponent: Wide variation is due to failure to correctly set the black level. 指数本身的变化范围相当狭窄,大约在 2.35 到 2.55 之间。所谓的广泛变化来自方程中的偏移项(offset term)变化,而不是指数:变化范围较大是由于未能正确设置黑电平。 |
Gamma correction is accomplished by inverting this equation. 伽马校正是通过对上述方程取反实现的。 |
Gamma correction is roughly the inverse of this equation, but two alterations must be introduced to achieve good perceptual performance. First, a linear segment is introduced into the transfer function, to minimize the introduction of noise in very dark areas of the image. Second, the exponent at the encoder is made somewhat greater than the ideal mathematical value, in order to impose a rendering intent that compensates for subjective effects upon image display. 伽马校正大致是这个方程的逆过程,但为了实现良好的感知性能,必须引入两个改动。首先,在转换函数中引入一个线性段,是为了将图像极暗部引入的噪声最小化。其次,编码器的指数值被设定得比理想数学值略大,以补偿图像显示时的渲染意图(rendering intent)。 |
CRT variation is responsible for wide variability in tone scale reproduction when images are exchanged among computers. 由于 CRT 的变化,计算机之间交换图像时色调再现的变化很大。 |
Poor performance in image exchange is generally due to lack of control over transfer functions that are applied when image data is acquired, processed, stored, and displayed. 图像交换中的性能差异通常是由于在图像数据获取、处理、存储和显示时缺乏对转换函数的控制。 |
Macintosh monitors have nonstandard values of gamma. Macintosh 显示器的伽马值是非标准的。 |
All CRT monitors, including those used with Macintosh computers, produce essentially identical response to voltage. But the Macintosh QuickDraw graphics subsystem involves a lookup table that is loaded by default with an unusual transfer function. It is the default values loaded into the lookup table, not the monitor characteristics, that impose the nonstandard Macintosh gamma. 所有 CRT 显示器,包括用于 Macintosh 计算机的显示器,对电压的响应基本相同。但 Macintosh 的 QuickDraw 图形子系统(译者注:QuickDraw 是苹果公司开发的一种图形库,用于处理图形和图像)涉及一个查找表,该表默认加载了一个不寻常的转换函数,该函数是加载到查找表中的默认值,而不是显示器特性,这导致了 Macintosh 的伽马是非标准的。 |
Gamma problems can be circumvented by loading a lookup table having a suitable gamma value. 通过加载具有合适伽马值的查找表可以规避伽马问题。 |
Loading a particular lookup table, or a particular value of gamma, alters the relationship of data in the frame buffer to linear-light “intensity” (properly, luminance, or tristimulus value). This may have the intended effect on a particular image. However, loading a new lookup table will disturb the code-to-luminance mapping that is assumed by the graphics subsystem, by other images, or by other windows. This is liable to alter color values that are supposed to stay fixed. 加载特定的查找表或特定的伽马值,会改变帧缓冲器中数据与线性光“强度”(准确地说是光亮度或三刺激值)之间的关系,这可能对特定图像产生预期的效果。然而,加载新的查找表会扰乱图形子系统、其他图像或其他窗口假设的“码值到光亮度”的映射,这可能会改变本应保持固定的颜色值。 |
Macintosh computers are shipped from the factory with gamma set to 1.8. SGI machines default to gamma of 1.7. To make an SGI machine display pictures like a Mac, set SGI gamma to 1.8. Macintosh 计算机出厂时设置的伽马值为 1.8。SGI 机器的默认伽马为 1.7。要让 SGI 机器显示的图像像 Mac 一样,需要将 SGI 的伽马设置为 1.8。 |
On the Macintosh, setting a numerical gamma setting of g loads into the framebuffer’s lookup table a power function with the exponent g ⁄ 2.61 . On an SGI, setting a numerical gamma setting of g loads into the lookup table a power function with the exponent 1 ⁄ g . To make an SGI machine behave like a Mac, you must set SGI gamma to 1.45. 在 Macintosh 上,设置伽马数值为 g 会将幂函数加载到帧缓冲器的查找表中,其指数为 g/2.61。在 SGI 上,设置数值伽马值 g 会将幂函数加载到查找表中,其指数为 1/g。要使 SGI 机器的表现像 Mac,需要将 SGI 的 Gamma 设置为 1.45。 |
Gamma problems can be avoided when exchanging images by tagging every image file with a suitable gamma value. 交换图像时,通过为每个图像文件标记一个合适的伽马值可以避免伽马问题。 |
Various tag schemes have been standardized; some tags are coded into image files. However, application software today generally pays no attention to the tags, so tagging image files is not helpful today. It is obviously a good idea to avoid subjecting an image file to cascaded transfer functions during processing. However, the tag approach fails to recognize that image data should be originated and maintained in a perceptually-based code. 各种标签方案已经标准化,有些标签编码在图像文件中。然而,现今的应用软件通常不会注意这些标签,因此对图像文件进行标记在今天并没有帮助。显然,在处理过程中避免对图像文件应用级联转换函数(cascaded transfer functions)是个好主意。然而,标签方法未能认识到图像数据应在感知基础上的编码中生成和维护。 |
JPEG compresses RGB data, and reproduces RGB data upon decompression. The JPEG algorithm itself is completely independent of whatever transfer function is used. JPEG 压缩 RGB 数据,并在解压时重现 RGB 数据。JPEG 算法本身完全独立于所使用的任何转换函数。 |
JPEG and other lossy image compression algorithms depend on discarding information that won’t be perceived. It is vital that the data presented to a JPEG compressor be coded in a perceptually-uniform manner, so that the information discarded has minimal perceptual impact. Also, although standardized as an image compression algorithm, JPEG is so popular that it is now effectively an image interchange standard. Standardization of the transfer function is necessary in order for JPEG to meet its users’ expectations. JPEG 和其他有损图像压缩算法依赖于丢弃不会被感知的信息。因此,向 JPEG 压缩器提供的数据必须以感知均匀的方式编码,以便丢弃的信息对感知影响最小。此外,尽管 JPEG 被标准化为图像压缩算法,但由于其使用的广泛性,它现在实际上是图像交换标准。为了使 JPEG 满足用户的期望,转换函数的标准化是必要的。 |
Intensity 强度
Intensity is the rate of flow of radiant energy, per unit solid angle – that is, in a particular, specified direction. In image science, we measure power over some interval of the electromagnetic spectrum. We’re usually interested in power radiating from or incident on a surface. Intensity is what I call a linear-light measure, expressed in units such as watts per steradian.
强度是每单位立体角内辐射能量的流速,也就是特定方向上的辐射强度。在图像科学中,我们测量电磁光谱某个区间内的功率,通常关注从表面发出的或落在表面上的辐射功率。强度是对线性光的一种度量,用瓦特每立体角(watts per steradian)表示。
The CIE has defined luminance, denoted Y, as intensity per unit area, weighted by a spectral sensitivity function that is characteristic of vision. The magnitude of luminance is proportional to physical power; in that sense it is like intensity. But the spectral composition of luminance is related to the brightness sensitivity of human vision.
国际照明委员会(CIE)定义了光亮度,用 Y 表示,作为每单位面积的强度,并按视觉特性的光谱灵敏度函数加权。光亮度的大小与物理功率成正比,在这方面它与强度类似。但光亮度的光谱组成与人类视觉的视亮度敏感度(brightness sensitivity)有关。
Luminance can be computed as a properly-weighted sum of linear-light (tristimulus) red, green, and blue primary components. For contemporary video cameras, studio standards, and CRT phosphors, the luminance equation is this:
光亮度可以通过线性光(线性三刺激值)的红、绿、蓝主色分量的适当加权和来计算。对于现代摄影机、工作室标准和 CRT 荧光粉,光亮度方程为:
Video equipment forms a luma component Y’ as a weighted sum of nonlinear R’G’B’ primary components. The nonlinear quantity is often incorrectly referred to as luminance by video engineers who are unfamiliar with color science.
视频设备采用非线性 R’G’B’ 主色分量的加权和来计算 Y’ 非线性亮度分量(luma component),不了解色彩科学的视频工程师往往错误地将这个非线性量称为光亮度。
The luminance generated by a physical device is usually not proportional to the applied signal – usually, there is a nonlinear relationship. A conventional CRT has a power-law response to voltage: Luminance produced at the face of the display is approximately the applied voltage raised to the five-halves power. The numerical value of the exponent of this power function, 2.5, is colloquially known as gamma. This nonlinearity must be compensated in order to achieve correct reproduction of luminance. An example of the response of an actual CRT is graphed, at three settings of the CONTRAST control, in Figure 1 above. [1]
物理设备产生的光亮度通常与施加的信号不成比例,存在非线性关系。传统 CRT 对电压的响应是符合幂函数的:显示屏表面产生的光亮度约为施加电压的 2.5 次幂。这个幂函数的指数值 2.5 被称为伽马。为了正确再现光亮度,必须补偿这种非线性。图 1 展示了实际 CRT 在对比度(CONTRAST)控制的三种设置下的响应。

Figure 1 CRT’s transfer function is shown at three different settings of the CONTRAST (or PICTURE) control. Here I show CONTRAST altering the y-axis (luminance) scaling; owing to the properties of a power function, scaling the x-axis (video signal) has an equivalent effect. The graph indicates a video signal having a voltage from zero to 700 mV. In a typical eight-bit digital-to-analog converter in a computer graphics subsystem, black is at code zero, and white is at code 255.
图 1 显示了在三种不同对比度(CONTRAST 或 PICTURE)设置下的 CRT 转换函数。这里展示了对比度设置的变化如何对 y 轴(光亮度)进行缩放;由于幂函数的性质,缩放 x 轴(视频信号)也会产生相同的效果。图表展示了电压从零到 700 毫伏的视频信号。在典型的计算机图形子系统的 8 位数模转换器中,黑色对应码值零,白色对应码值 255。
It is alleged that the power function exponent γ of a CRT varies over a wide range; values as low as 1.4 and as high as 3.5 are cited in the literature. The graphs and captions in Figures 4 and 6 opposite show that wide variation in the apparent gamma value will result if the monitor’s BLACK LEVEL (or “BRIGHTNESS”) control is improperly adjusted. [2]
很多人声称 CRT 的幂函数指数
At a particular level of adaptation, human vision responds to about a hundred-to-one contrast ratio of luminance from white to black. Within this range, vision has a nonlinear response to luminance: Lightness perception is roughly logarithmic. A source having a luminance only 18% of a reference luminance appears about half as bright. The perceptual response to luminance is called Lightness. Vision researchers have modeled lightness sensitivity with various mathematical functions, as shown in Figure 2 below.
在特定的适应水平下,人类视觉可以感知从白到黑的约 100:1 的光亮度对比度。在这个范围内,视觉对光亮度的响应是非线性的,即明度感知大致是对数关系。一个光亮度为参考光亮度 18%的光源,看起来是参考光源的 50%那么亮。对亮度的这种感知称为“明度”。视觉研究人员使用各种数学函数来建模明度敏感度,如图 2 所示。

Figure 2 Luminance and lightness. The relationship between lightness-scale value V and luminance factor Y is plotted in accordance with different formulae. Redrawn from Fig. 2 (6.3) from Wyszecki and Stiles, Color Science (New York: Wiley, 1982).
图 2:光亮度和明度。 根据不同公式绘制了明度值 V 与光亮度因子 Y 之间的关系。图表重新绘制自 Wyszecki 和 Stiles 的《色彩科学》(纽约:Wiley, 1982)中的图 2(6.3)。
The CIE has adopted a standard function L* (pronounced “EL-star”), defined as a modified cube root: [3]
国际照明委员会(CIE)采用了一种标准函数 L*(读作“EL-star”),定义为修正后的立方根:
Y n is the luminance of the white reference. A linear segment with a slope of 903.3 is applied near black. L* has a range of 0 to 100. A unit change in L* is taken to be approximately the threshold of visibility. In other words, you can detect a difference between intensities when the ratio between them is greater than about one percent.
其中,

Figure 3 BRIGHTNESS control has the effect of sliding the black-to-white video signal scale left and right along the 2.5-power function of the display. Here, BRIGHTNESS is set too high; a significant amount of luminance is produced at zero video signal level. No video signal can cause true black to be displayed, and the picture content rides on an overall pedestal of gray. Contrast ratio is degraded.
图 3:“视亮度”(BRIGHTNESS)控制 的效果,是通过沿显示器的 2.5 次幂函数左右移动黑白视频信号的起始位置来实现的。在本图中,“视亮度”(BRIGHTNESS)设置过高,使得在视频信号电平为 0 时也会产生显著的光亮度。这导致没有视频信号能显示真正的黑色,图像内容整体落在一个底灰信号之上,使得对比度下降。

Figure 4 Gamma 3.5 A naive approach to the measurement of CRT nonlinearity is to model the response as L = (V’) γ , and to find the exponent of the power function that is the best fit to the voltage-to-intensity transfer function of a particular CRT. However, if this measurement is undertaken with BRIGHTNESS set too high, an unrealistically large value of gamma results from the modelled curve being “pegged” at the origin.
图 4:Gamma 3.5 的由来。 对 CRT 非线性进行测量的一种简单方法是将响应建模为
,并找到最符合特定“CRT 电压-强度”转换函数的幂函数的指数。然而,如果在“视亮度”(BRIGHTNESS)设置得过高的情况下进行测量,那么由于这种简单建模的曲线是“固定”通过原点的,将导致计算得到的伽马值比实际要大得多。

Figure 5 BRIGHTNESS control set too low causes a range of input signal levels near black to be reproduced “crushed” or “swallowed,” reproduced indistinguishably from black. A cinematographer might refer to this situation as “lack of details in the shadows,” however, all information in the shadows is lost, not just the details.
图 5:“视亮度”(BRIGHTNESS)控制设置过低,会导致接近黑色的一系列输入信号水平产生“压缩”或被“吞噬”,无法与黑色区分开来。电影摄影师可能会将这种情况称为“缺乏暗部细节”,但实际上暗部的所有信息都丢失了,而不仅仅是细节。

Figure 6 Gamma 1.4 If the transfer function is modelled as L = (V’) γ with Black Level set too low, an unrealistically small value of gamma results. However, if the transfer function is modeled with a function of the form L = (V’+ ε ) 2.5 that accommodates black level error, then a good fit is achieved. Misintepretations in the measurement of CRT nonlinearity have led to assertions about CRTs being highly unpredictable devices, and have led to image exchange standards employing quite unrealistic values of gamma.
图 6:Gamma 1.4 的由来。 如果在黑电平设置过低的情况下将转换函数建模为
,则得到的伽马值比实际要小得多。然而,如果转换函数建模为 的形式,可以容纳黑电平误差,则可以得到良好的拟合。对 CRT 非线性函数的误解,导致了对 CRT 电光转换特性“高度不可预测”的错误断言,并导致图像交换标准采用了不现实的伽马值。
Linear light coding 线性光编码
Suppose that you wish to convey luminance values of an image through a channel having a few hundred or a few thousand discrete levels. Consider linear light coding, sketched in the margin, where code zero represents black. No matter what code is at the top end, code 100 represents a shade of gray that lies approximately at the perceptual threshold. For codes below 100, the ratio of intensities between adjacent code values is greater than 1 percent. At code 25, the ratio between adjacent codes is 4 percent. In smooth-shaded regions of an image, the luminance difference between adjacent code values, such as between code 25 and code 26, will cause visible banding or contouring. For codes above 100, the ratio of luminance values between adjacent codes is less than 1 percent: Code 201 is perceptually useless, and could be discarded without being noticed. In an 8-bit system, the highest code value – the brightest white – is at code 255. In an 8-bit linear-light system, the ratio between the brightest white and the darkest grey that can be reproduced without contouring is a mere 2.55:1.
假设我们希望通过一个具有几百或几千个离散级别(levels)的通道传递图像的光亮度值。考虑对光信号进行线性编码,如图 7 所示,其中码值零表示黑色。无论最高码值是多少,码值 100 都表示大约在感知阈值处的灰色阴影(译者注:这里指的是相邻码值间的光亮度差异 △ = 1% 在人眼恰可察觉的阈值处)。对于低于 100 的码值,相邻码值之间的光亮度之比大于 1%。在码值 25 处,相邻码值之间的光亮度之比是 4%。在图像的平滑阴影区域,相邻码值之间的光亮度差异(如码值 25 和 26 之间)会导致可见的条纹(banding)或轮廓(contouring)。在超过 100 的码值中,相邻码值之间的光亮度之比小于 1%。码值 201 在感知上是无用的(译者注:因为 201 与 200 所代表的光亮度之比 △ = 0.5% 小于恰可察觉阈值,其差别是人眼不可感知的),可以被丢弃而不会被注意到。在 8 位系统中,最高码值——最亮的白色——是码值 255。在 8 位线性光系统中,最亮的白色和最暗的灰色之间的比率仅为 2.55:1。

Figure 7 Linear light coding: the code 100 problem
图 7:线性光编码的码值 100 问题
To avoid perceptible steps at the black end of the scale, it is necessary to have coding that represents different luminance levels 1.00, 1.01, 1.02, and so on. If linear light coding is used, an absolute “delta” of 0.01 must be maintained all the way up the scale to white. To encompass the 100:1 luminance range vision of requires about 9900 codes, or about 14 bits for each of the R, G, and B components of the image.
为了避免在黑端出现可感知的步长(steps),必须有编码来表示不同的光亮度水平 1.00,1.01,1.02,等等。如果使用线性光编码,则必须在整个范围内保持绝对“增量”0.01,从黑色一直编码到白色。要覆盖 100:1 的光亮度范围需要大约 9900 个码值(译者注:(100-1) / 0.01 ),或大约 14 位数据(译者注:2^13 = 8192,2^14 = 16384),用于图像的 R、G、B 分量。
If you use nonlinear coding, then the 1.01 “delta” required at the black end of the scale applies as a ratio – not as an absolute increment – and progresses like compound interest up to white. This results in about 463 codes, or about nine bits per component. Eight bits, nonlinearly coded according to Rec. 709, is sufficient for broadcast-quality digital television at a contrast ratio of about 50:1. [4]
如果使用非线性编码,则暗部所需的 1.01“增量”是作为比率而非绝对增量来使用的,如同复利(compound interest)一样,从黑色向白色递增。这需要大约 463 个码值(译者注:1.01^462 = 99.19,1.01^463 = 100.18),或者大约每个分量 9 位数据。Rec. 709 所采用的非线性 8 位编码,足以用于广播级数字电视的 50:1 对比度。
In computer-generated imagery (CGI), linear-light coding is typically used in the frame buffer, as sketched in Figure 8 above. Often only 8 bits are provided in the framebuffer. When luminance data traverses the 8-bit Bottleneck indicated in the sketch, serious contouring results.
在计算机生成图像(CGI)中,帧缓冲器通常采用线性光编码,如图 8 所示。帧缓冲器中通常只提供 8 位的位深。当光亮度数据通过草图中所示的“8 位瓶颈”(8-bit bottleneck)时,会导致严重的轮廓(contouring)问题。

Figure 8 Gamma in computer-generated imagery (CGI)
图 8:计算机生成影像(CGI)中的伽马
Video coding 视频编码
To code luminance into a small number of steps, say 256, then the codes should be assigned to intensities according to the properties of perception, in order for the most effective perceptual use to be made of the available codes. A transfer function similar to the lightness sensitivity of vision should be imposed at encoding.
为了将光亮度用较少的阶数(如 256 阶)编码,应该根据感知特性将码值分配给光强度,从而最有效地利用可用的码值。在编码时,应施加类似于明度敏感度的转换函数。
A CRT’s response is very nearly the inverse of the lightness sensitivity of vision: When image data is coded for perception at the encoder – for example, by the Rec. 709 transfer function graphed in Figure 9 above the coding is inverted by the CRT, without the necessity to dedicate any circuitry to the task. The fact that a CRT’s transfer function is very nearly the inverse of the lightness sensitivity of vision is an amazing, and fortunate, coincidence! The Rec. 709 transfer function standardized for 525/59.94 studio video, 625/50 studio video, and HDTV.
CRT 的响应几乎是明度敏感度的反函数:当图像数据在编码器处进行感知编码时,比如通过图 9 中绘制的 Rec. 709 转换函数编码时,CRT 的特性会天然地将编码反转,而无需专门的电路来完成这一任务。CRT 的转换函数几乎是明度敏感度的反函数,这真是一个令人惊奇和幸运的巧合!**Rec. 709 转换函数已标准化并用于 525 线/59.94i 的 NTSC 制模拟电视信号,625 线/50p 的 PAL 制模拟电视信号,以及高清电视(HDTV)信号。

Figure 9 The Rec. 709 transfer function of video mimics the lightness sensitivity of vision. The standard is based on a power function with an exponent of 0.45. Theoretically, a pure power function suffices for gamma correction. In a practical system such as a television camera, the slope of the function is limited near zero in order to minimize noise in the dark regions of the picture.
图 9:Rec. 709 转换函数,它模仿了人眼对明度(Lightness)变化的敏感度。该标准基于一个指数为 0.45 的幂函数。理论上,纯幂函数就足以实现伽马校正。然而,在实际系统如电视摄影机系统中,为了减少图像暗区的噪声,函数在接近零的地方斜率会受到限制。
A summary sketch of gamma in video is shown in Figure 10 below. At the camera, luminance (or, in a color system, a set of three tristimulus values) is subjected to the Rec. 709 transfer function – or loosely, gamma correction – whose graph resembles the lightness sensitivity of vision. Video data is stored, processed, recorded, and transmitted in the perceptual domain. The monitor inverts the transform. The main purpose of gamma correction is to code luminance into a perceptually uniform domain, so as to obtain the best perceptual performance from a limited number of bits in each of R’, G’, and B’. (The prime symbols denote the nonlinearity.)
图 10 以草图的形式总结了伽马在视频中的应用。摄影机将光亮度(在彩色系统中是一组三刺激值)通过 Rec. 709 转换函数进行处理(或粗略地说,进行伽马校正),该函数的图像类似于人眼视觉的明度敏感度。视频数据在感知域中存储、处理、记录和传输。显示器对该变换进行反转。伽马校正的主要目的是将光亮度编码到感知均匀的域中,从而在每个非线性 R’、G’和 B’信号(撇号表示非线性)的有限位深中获得最佳的感知性能。

Figure 10 Gamma in video
图 10:视频中的伽马
Rendering intent 渲染意图
Nonlinear encoding involves applying a transfer function similar to the lightness sensitivity of human vision. Ideally, luminance would first be matrixed, that is, formed as a weighted sum of linear-light (tristimulus) RGB signals. Then, the CIE L* transfer function would be applied, to code the signal into a perceptually uniform domain. At the decoder, the inverse of the L* function would restore luminance, then the inverse matrix would reconstruct RGB. The L* signal would be accompanied by two other signals, to enable the representation of color:
非线性编码涉及应用一个类似于人类视觉明度敏感度的转换函数。理想情况下,首先将光亮度进行矩阵变换,即将线性光(三刺激值)RGB 信号按权重求和。然后,应用 CIE L* 转换函数,将信号编码到一个感知均匀的域中。在解码端,通过 L* 函数的反函数恢复光亮度,再通过逆矩阵重建 RGB。L* 信号会配合另外两个信号,以便表示颜色:

Coding L* with eight bits achieves good image quality. Coding Y directly would require 11 bits or more to achieve similar quality.
使用 8 位编码 L* 可以实现良好的图像质量,直接编码 Y 则需要 11 位或更多才能达到相似的质量。
As I have outlined, the electron gun of a CRT monitor introduces a power function having an exponent of about 2.5:
如我所述,CRT 显示器的电子枪引入了一个指数约为 2.5 的幂函数:

If we were to encode according to the L* function, the decoder would have to invert that function, then impose the inverse of the 2.5-power function of the CRT:
如果我们按照 L* 函数进行编码,解码器需要先对该函数进行反转,然后再施加 CRT 的 2.5 次幂函数的反函数:

The CRT’s power function is so similar to the inverse of the L* function that we make an engineering compromise: Instead of encoding Y using the L* transfer function, we encode RGB intensities to the inverse of the CRT’s function. This allows us to dispense completely with transfer function circuitry at the display. We must then interchange the order of the matrix and the transfer function at the encoder. Changing the order of operations causes a departure from the Principle of constant luminance. In theory, the encoder would require a 0.4-power function:
CRT 的幂函数与 L* 函数的反函数非常相似,因此我们做出了工程上的妥协:我们不使用 L* 转换函数对光亮度(Y)进行编码,而是将 RGB 强度编码为 CRT 函数的反函数。这样,我们就无需在显示器上使用转换函数电路。我们必须在编码器处交换矩阵和转换函数的顺序。改变操作顺序会违背恒定光亮度原理。理论上,编码器需要一个 0.4 次幂函数:

This arrangement reproduces physical luminance correctly. However, it has a serious problem: The pictures do not look very good! When viewing a reproduced image, human viewers prefer a reproduction whose contrast ratio has been stretched slightly to a reproduction that is physically correct. The subjective preference depends somewhat upon the viewing environment. In effect, the visual system of the viewer imposes a power function with an exponent of about 1 ⁄ 1.25 :
这种方法可以正确再现物理光亮度,但有一个严重问题:图像看起来不够好!观众更喜欢对比度稍微拉伸的图像,而不是物理上完全正确的图像。主观偏好在一定程度上取决于观看环境。实际上,观众的视觉系统施加了一个指数约为 1/1.25 的幂函数:

For television, a power function with an exponent of about 1.25 must be applied to overcome this effect, in order to produce images that are subjectively pleasing. Rather than introducing circuitry at the display to apply this function, we modify the transfer function at encoder. We use an exponent of about 0.5, instead of the physically-correct 0.4:
对于电视来说,为了产生主观上令人满意的图像,必须应用一个指数约为 1.25 的幂函数来补偿这一效果。与其在显示端引入电路来应用这个函数,不如在编码器处修改转换函数。我们使用约 0.5 的指数,而不是物理上正确的 0.4:

If you think of encoding in physical terms, you could consider a video image to be encoded such that a 2.0-power function would reproduce physically-correct luminance at the display. (The NTSC video standard is often said to have gamma of 2.2, because the FCC standards described gamma in this way.) However, I think it is more evocative consider the application of the power function at the encoder to impose a rendering intent upon the image data. The encoding assumes the image is to be reproduced in a subjectively-acceptable manner through a physical 2.5-power function at the display.
如果从物理角度来看编码,可以认为视频图像的编码方式,是为了满足在显示端通过一个 2.0 次幂函数来再现物理上正确的光亮度。(NTSC 视频标准常被认为有 2.2 的伽马,因为 FCC 标准这样描述伽马。)然而,我认为更有意义的是在编码器上应用幂函数,以对图像数据施加渲染意图。这种编码假设图像将在显示端通过 2.5 次幂函数以主观上可接受的方式再现。
Though ubiquitous in video, this subjective correction is rarely considered explicitly in computer graphics; belief in the “bits are bits” philosophy suggests to programmers that luminance should be reproduced in the physically-correct manner. However, subjective correction is as necessary in computer graphics as it is in video, and the Rec. 709 transfer function is appropriate for computer graphics. In traditional computer-generated imagery (CGI), as in Figure 8, the subjective correction is typically accomplished by “gamma correction” using a 1 ⁄ 2.2 -power function (instead of 1 ⁄ 2.5 ). This is called “gamma of 2.2”.
尽管在视频中无处不在,这种主观校正在计算机图形中很少被明确考虑;“比特即比特”的理念让程序员认为光亮度应以物理上正确的方式再现。然而,计算机图形中同样需要主观校正,Rec. 709 转换函数适用于计算机图形。在传统的计算机生成图像(CGI)中,如图 8 所示,主观校正通常通过使用 1/2.2 次幂函数(而不是 1/2.5)的“伽马校正”来完成,这被称为“伽马 2.2”。
The Rec. 709 transfer function is standard for 525/59.94 and 625/60 conventional video, and for HDTV. The Rec. 709 function is based on a power function exponent of 0.45, but the pure power function is modified by the insertion of a linear segment near black. The overall function is very similar to a square root. For details, consult the Gamma chapter in my book. In the diagrams in this section, I use the notation 0.5 as shorthand for the Rec. 709 function. [5]
Rec. 709 转换函数是 525 线/59.94i 的 NTSC 制模拟电视信号,625 线/50p 的 PAL 制模拟电视信号,以及高清电视(HDTV)的标准。Rec. 709 函数基于 0.45 的幂函数指数,但在接近黑色的地方插入了线性段,对纯幂函数进行了修改,整体函数非常类似于平方根,详情请参阅我的著作中的“伽马”一章。在本节的图表中,我用 0.5 作为 Rec. 709 函数的简写。
Rec. 709 appears to strictly define the transfer function at the camera. However, real video cameras have controls that can alter the transfer function. These controls are routinely used by cinematographers and videographers to achieve their artistic intents. Obviously the artistic intention of the cinematographer must be imposed at the camera, not at the display – it ought to be the displays that are standardized, not the cameras! But there is no mechanism to impose standards on displays, so we standardize the reference transfer function at the camera instead. In effect, Rec. 709 is standardized so as to produce acceptable reproduction on a conventional display. Despite the lack of standards, CRT displays are tacitly considered to have similar response.
尽管 Rec. 709 严格定义了摄影机的转换函数,但实际的视频摄影机提供了可以改变转换函数的控制功能。这些控制通常被电影摄影师和摄像师用来实现他们的艺术意图。显然,电影摄影师的艺术意图必须在摄影机上实现,而不是在显示端实现——应该标准化的是显示器,而不是摄影机!但由于目前尚无机制对显示器施加标准(译者注:BT. 1886 是 2011 年发布的),所以我们选择在摄影机对参考转换函数进行标准化。实际上,Rec. 709 的标准化工作,是为了在传统显示器上产生可接受的再现效果。尽管缺乏标准,但默认 CRT 显示器的响应都是类似的。
The engineering of video systems – and, by extension, of desktop computer systems – involves an implicit assumption about the 2.5-power function of the monitor. Alternate display devices, such as LCDs, plasma panels, DMDs, and so on, do not have the 2.5-power function of the CRT. But the most important aspect of image coding is the establishment of a nearly perceptually-uniform image code. In a closed system employing an alternate display technology, you might be tempted to use of a transfer function at encoding that is the inverse of the transfer function at the display. However, if the transfer function of the display was very different than a 2.5-power function, more than 8 bits would be required to code luminance.
视频系统(以及延伸到桌面计算机系统)的工程设计,隐性假设了显示器的转换函数是 2.5 次幂函数。其他可选的显示设备,如 LCD、等离子显示器、DMD 等,没有 CRT 的 2.5 次幂函数。但图像编码最重要的考虑是建立一个接近感知均匀的图像编码。在使用其他显示技术的封闭系统中,你可能会倾向于在编码时使用显示端转换函数的反函数。然而,如果显示器的转换函数与 2.5 次幂函数非常不同,则需要超过 8 位来编码光亮度。
More significantly, there is a huge installed base of encoding and decoding equipment that assumes image coding similar or identical to that of video. The installed base includes roughly 1,300,000,000 television receivers, 400,000,000 VCRs, 250,000,000 camcorders, and 300,000,000 desktop computers. These devices are all, in effect, wired to directly reproduce R’G’B’ signals encoded according to Rec. 709. Any proposal for a new encoder transfer function would compromise the interchange of images among these systems.
更重要的是,有大量已安装的编解码设备,可以认为这些设备的图像编码与上述视频标准是相同或类似的。已安装的设备包括大约 13 亿台电视接收器,4 亿台录像机,2.5 亿台摄影机和 3 亿台桌面计算机。这些设备实际上都直接按照 Rec. 709 编码的 R’G’B’信号进行影像再现。任何对新的编码器转换函数的提议,都会影响这些系统之间图像的交换。
I have discussed the reproduction of black-and-white images. These concepts extend into the domain of luma and color difference coding, used in video, JPEG, and MPEG. At a SMPTE conference, I discussed the effect of transfer functions in luma and color difference coding. [6]
我已经讨论了黑白图像的再现。这些概念也扩展到视频、JPEG 和 MPEG 中使用的非线性亮度分量(luma)和色差编码领域。在 SMPTE 会议上,我讨论了转换函数在非线性亮度分量和色差编码中的作用。
Pseudocolor, hicolor, and truecolor 伪彩色、高彩色和真彩色
The block diagrams of pseudocolor, hicolor, and truecolor systems used in desktop computing are sketched in Figures and opposite. These sketches show the hardware pipeline from the framebuffer to the monitor. The interface from application software to the graphics subsystem (and window system) assumes the same processing. Comparable processing is implicit in file formats for pseudocolor and truecolor images. (File formats for hicolor are rare.)
桌面计算中使用的伪彩色、高彩色和真彩色系统的框图分别在下方草图中展示,这些草图呈现了从帧缓冲器到显示器的硬件流程。从应用软件到图形子系统(及视窗系统)的接口,都可以认为采用相同的处理方式。伪彩色和真彩色图像的文件格式中隐含了类似的处理流程。(高彩色的文件格式比较罕见。)
A pseudocolor image is always accompanied by its color lookup table (CLUT). The CLUT may be optimized for the particular image, or it may contain a system palette. Upon display of a pseudocolor image, the graphics subsystem may directly load the colormap that accompanies the image. Alternatively, the graphics subsystem may recode the image according to some other map that is already loaded into the hardware, or according to the system palette native to the application. Recoding of pseudocolor image data may introduce color errors. Pseudocolor image data is always coded in terms of monitor R’G’B’ – that is, pseudocolor image colors are implicitly perceptually coded.
伪彩色图像总是附带一个颜色查找表(CLUT)。CLUT 可以为特定图像优化,也可以包含系统调色板(system palette)。在显示伪彩色图像时,图形子系统可以直接加载随图像附带的色彩图(colormap)。或者,图形子系统可以根据已加载到硬件中的其他色彩图或应用程序的系统调色板重新编码图像。重新编码伪彩色图像数据可能会引入颜色误差。伪彩色图像数据总是以显示器的 R’G’B’ 编码,这意味着伪彩色图像的颜色是隐含地按照感知进行编码的。

Figure 11 Pseudocolor (8-bit) graphics systems are common in low-end PCs. For each pixel, the framebuffer stores a color index value (typically 8 bits). Each index value is mapped, through a color lookup table (CLUT) that is part of the display hardware, to a triplet of R’G’B’ codes. When a pixel is accessed from the framebuffer, the corresponding triplet is accessed from the CLUT; those values are applied to the digital-to-analog converter (DAC). R’G’B’ codes from the CLUT translate linearly into voltage applied to the monitor, so code values are comparable to video R’G’B’ values – the R’G’B’ values are proportional to displayed intensity raised to the 0.4 power, comparable to video R’G’B’ codes.
图 11:伪彩色(8 位) 图形系统在低端 PC 中很常见。对于每个像素,帧缓冲器存储一个颜色索引值(通常为 8 位)。每个索引值通过显示硬件中的颜色查找表(CLUT)映射为一个 R’G’B’ 三元组。当从帧缓冲器读取一个像素时,相应的三元组从 CLUT 中读取,并应用于数模转换器(DAC)。从 CLUT 获取的 R’G’B’ 码值线性转换为施加到显示器的电压,因此码值可以类比为视频 R’G’B’ 值——这些 R’G’B’ 值与显示光强度的 0.4 次幂成正比,与视频 R’G’B’ 码值相当。
A hicolor system has no lookup tables. Image data is coded in terms of monitor R’G’B’: Image data is implicitly perceptually coded (though coarsely quantized).
高彩色系统没有查找表。图像数据以显示器的 R’G’B’ 编码:图像数据隐含地按照感知进行编码(尽管量化较为粗糙)。

Figure 12 Hicolor (16-bit) graphics systems store, in the framebuffer, R’G’B’ codes partitioned into three components of five bits each (5-5-5), or partitioned five bits for red, six bits for green, and five bits for blue (5-6-5). In low-end systems, these codes are applied directly to the DACs with no intervening colormap. Because the R’G’B’ codes are translated linearly into monitor voltage, the code values are implicitly proportional to displayed intensity raised to the 0.4 power.
图 12:高彩色(16 位) 图形系统在帧缓冲器中存储 R’G’B’ 码值,每个码值分为三个五位分量(5-5-5),或五位红色、六位绿色和五位蓝色(5-6-5)。在低端系统中,这些码值直接应用于数模转换器,没有中间色彩图。因为 R’G’B’ 码值线性转换为显示器电压,码值值隐含地与显示光强度的 0.4 次幂成正比。
In truecolor, each of the RGB channels is associated with a lookup table (LUT) that applies a transfer function. (Ordinarily, the three tables have identical contents.) Different default lookup tables are in use, for different platforms. Truecolor image files are ordinarily stored without any lookup tables; most truecolor file formats make little or no provision for conveying the transfer function that is expected at display.
在真彩色系统中,每个 RGB 通道都关联一个一维查找表(LUT),用于施加转换函数。通常,这三个查找表的内容是相同的。不同的平台使用不同的默认查找表。真彩色图像文件通常不包含任何查找表;大多数真彩色文件格式几乎不提供转换函数的信息。

Figure 13 Truecolor (24-bit) graphics systems store 8 bits for each of the red, green, and blue components. Truecolor systems usually implement a set of lookup tables (LUTs) between the framebuffer memory and the DACs. The LUTs allow a transfer function to be imposed between the R’G’B’ codes and the DACs: The R’G’B’ values in the framebuffer need not be related to displayed intensity raised to the 0.4 power. Application software or system software can impose arbitrary functions. In order for the application software to provide the same default behavior as low-end pseudocolor and hicolor graphics systems, each LUT is set by default to a ramp corresponding to the identity (or unity) function.
图 13:真彩色(24 位) 图形系统中,红色、绿色和蓝色分量各使用 8 位存储。真彩色系统通常在帧缓冲器内存和数模转换器之间实现一组一维查找表(LUT)。LUT 允许在 R’G’B’ 码值和数模转换器之间施加一个转换函数:帧缓冲器中的 R’G’B’ 值不必与显示的强度的 0.4 次幂相关。应用软件或系统软件可以施加任意函数。为了使应用软件提供与低端伪彩色和高彩色图形系统相同的默认行为,每个 LUT 默认设置为恒等函数(或单位函数)的斜坡(ramp)。
Hicolor and truecolor display hardware can typically be operated in pseudocolor mode. But this mode switch applies to the whole display. If a pseudocolor image is to be displayed in a window of a display that is operating in hicolor or truecolor mode, the graphics subsystem must perform the pseudocolor color lookup operation in software. If the truecolor system is operating with a LUT that is not a ramp, then the RGB codes from the pseudocolor CLUT must be mapped through the inverse of the truecolor LUT prior to being stored in the framebuffer.
高彩色和真彩色显示硬件通常可以在伪彩色模式下运行,但这种模式切换适用于整个显示器。如果要在运行高彩色或真彩色模式的显示器的窗口中显示伪彩色图像,图形子系统必须在软件中执行伪彩色查找操作。如果真彩色系统运行的 LUT 不是斜坡函数,那么来自伪彩色 CLUT 的 RGB 码值必须通过真彩色 LUT 的反函数映射,然后再存储到帧缓冲器中。
If a hicolor or truecolor image is to be presented on a display that is operating in pseudocolor mode, the graphics subsystem must find, for each hicolor or truecolor pixel (RGB triplet), the index of the closest color that is available in the CLUT currently in use. If the CLUT is organized systematically, then this operation can be fairly rapid; if the CLUT is unstructured, then the conversion proceeds slowly. The translation to pseudocolor causes coarse quantization of the image colors. Dithering may be applied, to spread the quantization error over a small area of the image. In any event, colormap quantization generally causes serious degradation of color fidelity.
如果要在运行伪彩色模式的显示器上显示高彩色或真彩色图像,图形子系统必须为每个高彩色或真彩色像素(RGB 三元组)找到当前 CLUT 中最邻近的颜色的索引。如果 CLUT 是系统化组织的,那么这个操作可以非常快速;如果 CLUT 是非结构化的,那么转换过程会非常缓慢。转换为伪彩色会导致图像颜色的量化较粗糙。可以应用抖动,将量化误差分散到图像的小区域中。无论如何,色彩图量化通常会严重降低颜色保真度。
A generic application program on a PC must assume the lowest common denominator of display capability: It must be prepared to operate without a lookup table. (Even some graphics cards with 24-bit capability have no lookup tables.) Even if a hardware lookup table is present, PC software generally operates as if there is no table. If a LUT is present, it is ordinarily loaded with a ramp so that it has no effect. Image data exchanged among PCs is therefore coded as monitor R’G’B’. Though the situation arose by accident, this is quite comparable to video coding, and is nearly optimal for perception! Image data that originates on (or is intended for display on) a PC carries the implicit assumption that the lookup table contains a ramp, that is, that the image data is represented in gamma-corrected monitor R’G’B’. So Figure 10 applies to video and to PCs: the coding is comparable.
在 PC 上的通用应用程序必须假设能够兼容最低的显示能力:它必须准备在没有查找表的情况下运行。(即使某些具有 24 位功能的显卡也没有查找表。)即使存在硬件查找表,PC 软件通常也假设不存在查找表。如果存在查找表,它通常被加载为斜坡函数,因此没有效果。所以,在 PC 之间交换的图像数据以显示器的 R’G’B’ 编码。尽管这种情况偶然发生,但这与视频编码非常相似,并且几乎是最佳的感知方式!在 PC 上生成(或用于在 PC 上显示)的图像数据包含一个隐含假设,即查找表包含斜坡函数,即图像数据以伽马校正后的显示器 R’G’B’ 表示。因此,图 10 适用于视频和 PC:编码是相似的。
Macintosh gamma 苹果电脑的伽马
Contrary to popular belief, Macintosh computers use monitors that have the same physics as monitors used in video systems and other brands of computers. Though it is nowhere documented in the 27 volumes of the Inside Macintosh series of books, the QuickDraw graphics subsystem loads an unusual transfer function into the lookup tables of a Mac. The default lookup table (in hexadecimal code) is this: [7]
与流行的看法相反,Macintosh 计算机使用的显示器与视频系统,和其他品牌计算机使用的显示器具有相同的物理特性。尽管在《Inside Macintosh》系列的 27 本书目中没有任何文档记录,但 QuickDraw 图形子系统会在 Mac 的查找表中加载一个不寻常的转换函数。默认的查找表(以十六进制码值表示)是这样的:

Figure 14 Default Macintosh LUT
图 14:默认的 Macintosh 查找表
This table contains a pure power function with an exponent of 1 ⁄ 1.45 . Image data that originates on – or is intended for display on a Macintosh computer carries the implicit assumption that the lookup table contains this function. This default lookup table, in combination with a conventional monitor, causes the R, G, and B values presented to QuickDraw to represent the 1 ⁄ 1.8 -power of luminance.
这个查找表包含一个指数为 1/1.45 的纯幂函数。在 Macintosh 计算机上生成的(或打算显示的)图像数据,默认假设查找表包含这个函数。这个默认查找表与传统显示器特性结合后,使得提供给 QuickDraw 的 R、G 和 B 值表示为光亮度的 1/1.8 次幂。
Although Apple has historically failed to publish any meaningful documentation of gamma, a Macintosh is widely considered to have a default gamma of 1.8. This de facto nomenclature was established by the Gamma control panel, by Knoll Software, which was distributed with Adobe Photoshop up to and including version 4.
虽然 Apple 在历史上从未发布任何关于伽马的详细文档,但 Macintosh 的默认伽马值通常被认为是 1.8。这一事实上的标准是由 Knoll Software 的 Gamma 控制面板确立的,该面板随 Adobe Photoshop 分发,包括第 4 版在内。
Figure 15 below summarizes the gamma situation for Macintosh.
下图 15 总结了 Macintosh 电脑的伽马情况。

Figure 15 Gamma in Macintosh
图 15:苹果 Macintosh 电脑的伽马
In the Gamma chapter of my book, I explain the dot gain phenomenon of offset printing. Offset printing uses code values proportional to the 1.8-power of reflectance. But QuickDraw RGB codes are related to luminance by the 1.8 power! Though the situation arose by accident, QuickDraw RGB coding is well suited to offset printing, and it is ubiquitous in desktop publishing and prepress. (QuickDraw coding is also widely used in multimedia, and on the World-wide Web, though in these applications it is not as suitable as coding according to Rec. 709.) [8]
在我的著作中的伽马一章,我解释了胶印(offset printing)中的网点扩大(dot gain)现象。(译者注:胶印指的是先把上墨的图像转移到橡皮布上,然后再转移到印刷材料表面的一种印刷方法,是平版印刷的一种;网点扩大指的是承印物上网点的有效面积大于加网底片上网点的有效面积,这会导致印刷出来的图像比设计的图像颜色更深或更饱和。)平版印刷使用的码值与反射率的 1.8 次幂相关,而 QuickDraw 的 RGB 码值恰好与光亮度的 1.8 次幂相关!虽然这种情况是一种偶然,但 QuickDraw 的 RGB 编码非常适合平版印刷,因此在桌面出版和印前处理中广泛使用。(尽管 QuickDraw 编码在多媒体和全球网络上也被广泛使用,但在这些应用中,它不如按 Rec. 709 编码那么适合。)
System issues 系统问题
Figure 16 above collects the three gamma sketches already presented (video, computer-generated imagery, and Macintosh), and adds a fourth sketch, for Silicon Graphics (SGI). Given the diverse transfer functions, it is no surprise that it is difficult to exchange image data.I have indicated in bold type the numerical quantity that is referred to as gamma in each of these four domains: You can see that the gamma number is applied in four different places! So even if you know the gamma value, it is difficult to determine where it is applied! As I have mentioned, a Macintosh is considered to have a default gamma of 1.8. An SGI computer has a default gamma of 1.7. But Figure 16 shows that these two numbers are not comparable!
图 16 汇总了之前展示的三个伽马相关的草图(视频、计算机生成图像、Macintosh),并添加了第四个草图,适用于 Silicon Graphics (SGI)。由于转换函数的差异,交换图像数据的困难可见一斑。我用粗体字标出了在这四个领域中称为伽马的数值量:你可以看到伽马数值应用在四个不同的位置!所以即使你知道伽马值,也很难确定它具体应用在哪里!如前所述,Macintosh 被认为默认伽马值为 1.8,SGI 计算机默认伽马值为 1.7,但图 16 显示这两个数值并不可比!

Figure 16 Gamma in video, PC, computer graphics, SGI, and Mac
图 16:视频、PC、计算机图形、SGI、Mac 的伽马
The graphics subsystems of most computers allow the lookup table to be changed. On a Mac, the Gamma control panel accomplishes this. When a gamma value of g is specified, the control panel loads the Mac lookup table with a power function whose exponent is g ⁄ 2.61 . When a gamma value of g is specified to an SGI computer, system software loads the SGI lookup table with a power function whose exponent is 1 ⁄ g . The convention differs from that on a Mac. To program an SGI computer to behave like a Mac, you must set SGI gamma to 1.45.
大多数计算机的图形子系统允许更改查找表。在 Mac 上,Gamma 控制面板完成此操作。当指定伽马值 g 时,控制面板加载一个指数为 g/2.61 的幂函数到 Mac 的查找表中。当指定伽马值 g 到 SGI 计算机时,系统软件加载一个指数为 1/g 的幂函数到 SGI 的查找表中。这一约定与 Mac 不同。要使 SGI 计算机表现得像 Mac,必须将 SGI 伽马设置为 1.45。
Image data in the framebuffer is not usually changed upon a change of the lookup table. Any time you jam a particular value of gamma into the back end of the graphics subsystem, you override assumptions that may have been made about the color interpretation of image data. When you change gamma, the colors of displayed objects (icons, menus, and windows) and the colors of displayed images, will change!
更改查找表时,帧缓冲器中的图像数据通常不会改变。任何时候你在图形子系统的末端插入一个特定的伽马值,都会覆盖之前关于图像数据颜色解释的假设。当你更改伽马值时,显示对象(图标、菜单和窗口)和显示图像的颜色都会改变!
Computer graphics standards 计算机图形标准
To exchange images using computer graphics standards requires knowledge of the transfer function. Standards such as PHIGS and CGM stem from computer-generated imagery (CGI), where linear-light (tristimulus) coding is the norm, and in PHIGS and CGM it is implicit that RGB data is coded in linear-light (tristimulus).
要使用计算机图形标准交换图像,必须了解转换函数。PHIGS 和 CGM 等标准源自计算机生成图像(CGI),通常采用线性光(三刺激值)编码。在 PHIGS 和 CGM 中,RGB 数据默认编码为线性光(三刺激值)。(译者注:PHIGS,Programmer’s Hierarchical Interactive Graphics System,程序员分层交互式图形系统,是一种用于渲染 3D 计算机图形的应用程序编程接口标准;CGM,Computer Graphics Metafile,计算机图形元文件,是一种免费、开放的国际标准文件格式,适用于 2D 矢量图形、光栅图形和文本,由 ISO/IEC 8632 定义)
JPEG and other lossy image compression algorithms depend on discarding information that won’t be perceived. It is vital that the data presented to a JPEG compressor be coded in a perceptually-uniform manner, so that the discarded information has minimal perceptual impact. In practice, JPEG works well only on nonlinearly-coded (gamma-corrected) image data.
JPEG 和其他有损图像压缩算法依赖于丢弃无法感知的信息。因此,提供给 JPEG 压缩器的数据必须以感知均匀的方式编码,以确保丢弃的信息对视觉感知的影响最小。实际上,JPEG 只能在经过非线性编码(伽马校正)的图像数据上良好运行。
But nowhere in the PHIGS, CGM, or JPEG standards is gamma or transfer function explicitly mentioned, and nowhere in the data streams or image file formats for PHIGS, CGM, or JPEG, is the transfer function conveyed! The user must handle the transfer function or face poor image quality. If image data is transferred between these systems without regard for the transfer function, then the pictures will have terrible quality. Figure 17 below summarizes the situation: RGB codes [128, 128, 128] produce completely different intensities at the face of the screen in PHIGS (or CGM) and JPEG. But the standards themselves provide absolutely no information concerning this issue.
然而,在 PHIGS、CGM 或 JPEG 标准中,并没有明确提到伽马或转换函数,在这些标准的数据流或图像文件格式中也没有转换函数的信息!用户必须自己处理转换函数,否则图像质量将会很差。如果在这些系统之间传输图像数据而不考虑转换函数,图像的质量将会非常糟糕。下图 17 总结了这种情况:在 PHIGS(或 CGM)和 JPEG 中,相同的 RGB 码值 [128, 128, 128] 在屏幕上产生的强度完全不同,但这些标准本身对这个问题没有提供任何信息。

Figure 17 Gamma in PHIGS, CGM, and JPEG. In the PHIGS and CGM standards there is no mention of gamma or transfer function, but it is implicit that image data is coded as linear-light tristimulus values. In the JPEG standard there is no mention of gamma or transfer function, but it is implicit that image data is gamma corrected.
图 17:PHIGS、CGM 和 JPEG 中的伽马。在 PHIGS 和 CGM 标准中没有提到伽马或转换函数,但默认图像数据编码为线性光三刺激值。在 JPEG 标准中没有提到伽马或转换函数,但默认图像数据进行了伽马校正。
Many other computer graphics standards ignore or discount transfer functions. Figure 18 above shows a screenshot of the Apple Macintosh Color Picker, which implements the textbook HSL representation of color. This presentation implies that all of the colors shown share the same lightness value, but clearly the disk is not uniformly shaded. The HSL representation has no objective basis in color science.
许多其他计算机图形标准也忽略或轻视转换函数。下图 18 显示了 Apple Macintosh 颜色选择器的截图,它实现了教材中的 HSL 颜色表示。这种表示暗示所有显示的颜色具有相同的明度值,但显然圆盘并没有均匀着色。HSL 表示在颜色科学中没有客观基础。

Figure 18 Lightness in HSL. Lightness, in its CIE definition, is a perceptual quantity. However, in the textbook HSL color representation used in computer graphics – here exemplified by Apple’s Macintosh Color Picker – no account is taken of transfer function. Apple implies that all of the shades in the disk have the same lightness of 50%. Does the disk appear uniformly shaded to you?
图 18:HSL 中的明度。根据 CIE 的定义,明度是一个感知量。然而,在计算机图形中使用的教材 HSL 颜色表示中——这里以 Apple 的 Macintosh 颜色选择器为例——没有考虑转换函数。Apple 暗示圆盘中的所有阴影具有相同的 50% 明度。这个圆盘看起来是均匀着色的吗?
World-wide web 万维网
The World-wide web uses GIF and JPEG file formats to convey images. (Other file formats are in use, but none of these are widely deployed.)
万维网使用 GIF 和 JPEG 格式来传送图像。(也有使用其他格式的,但没有这两种应用这么广泛。)
A GIF file represents an image in pseudocolor form. A web browser operating on a pseudocolor display does not attempt to reconcile the potentially conflicting CLUTs found among the several (or several dozen) GIF images that might share a window on the user’s monitor. Instead, a browser typically recodes every pseudocolor image into a browser palette comprising a 6×6×6 colorcube of monitor R’G’B’ codes. The browser palette comprises 216 colors. (To display GIF images on a hicolor or truecolor system, the browser’s graphics subsystem uses each file’s CLUT to translate each image to R’G’B’.)
GIF 文件以伪彩色形式表示图像。当在伪彩色显示器上运行的网络浏览器加载多个(或几十个)GIF 图像时,它不会尝试协调这些图像之间可能存在的 CLUT 冲突。相反,浏览器通常会将每个伪彩色图像重新编码为由显示器 R’G’B’ 码值组成的 6×6×6 色立方体的浏览器调色板。浏览器调色板包含 216 种颜色。(在高彩色或真彩色系统上显示 GIF 图像时,浏览器的图形子系统使用每个文件的 CLUT 将每个图像转换为 R’G’B’。)
JPEG image coding is based on truecolor. The JFIF specification is the de facto standard for JPEG file interchange. JFIF is unclear concerning the handling of transfer function. In practice, an image is encoded into JPEG using the encoding transfer function that is in effect for the platform that it is encoded on. A decoded JPEG image is displayed using the transfer function in effect on the platform upon which it is decoded. Figure 19 overleaf sketches the gamma situation for JPEG on the web. It’s chaos! Image data is exchanged among platforms without regard for the transfer function that will be applied upon display. The same file displays differently on different platforms!
JPEG 图像编码基于真彩色。JFIF 规范是 JPEG 文件交换的事实标准,但在处理转换函数方面不够明确。实际上,图像在编码为 JPEG 时,使用的是编码平台上生效的转换函数。解码后的 JPEG 图像在显示时使用解码平台上生效的转换函数。下图 19 描述了网络上 JPEG 的伽马情况,显示了不同平台之间的混乱。图像数据在平台之间交换时不考虑显示时将应用的转换函数,同一个文件在不同平台上的显示效果不同。

Figure 19 Gamma on the web. Image data is exchanged on the web without regard for the transfer function that will be applied at display. Consequently, the same image is displayed differently on different platforms. Here, the image originates on an SGI computer. In practice, the dominant platforms are PC and Mac.
图 19:网络上的伽马。图像数据在网络上交换时不考虑显示时将应用的转换函数,因此,同一图像在不同平台上的显示效果不同。这里的图像源自 SGI 计算机。实际上,主导平台是 PC 和 Mac。
In Figure 19 above, I show an image originating on an SGI computer. You can see that it is decoded in four different ways; in particular, it is reproduced incorrectly on PC and Mac, the dominant viewing platforms. If a JPEG image originates on a PC, it displays incorrectly on a Mac; if a JPEG image originates on a Mac, it displays incorrectly on a PC. The relatively low penetration of Macintosh computers in the marketplace might suggest that image origination should be optimized for PCs: let the Mac browsers do what they will. But the tools for image preparation and web page creation are much more capable on Macs than on PCs. A large fraction of web images are prepared on Macs, so the implicit Mac transfer function is important. [9]
在上图 19 中展示了一个源自 SGI 计算机的图像。你可以看到它在四种不同的方式下解码,尤其是在主流查看平台 PC 和 Mac 上,它显示不正确。如果 JPEG 图像源自 PC,它在 Mac 上显示不正确;如果 JPEG 图像源自 Mac,它在 PC 上显示不正确。由于市场上 Macintosh 计算机相对低的渗透率,可能会认为图像生成应该主要针对 PC 进行优化,而让 Mac 浏览器自行调整。但用于图像准备和网页创建的工具在 Mac 上更为强大。因此,很多网页图像是在 Mac 上准备的,隐含的 Mac 转换函数非常重要。
The second row of the sketch shows the CGI situation. In practice, images are rarely displayed through a LUT configured for CGI. But the VRML language stems from CGI, and shading in synthetic computer graphics has historically been performed in the linear-light domain. (Shading in nonlinear domains is poorly understood.) VRML is best considered to originate in the computer graphics row of the sketch.
草图的第二行显示了 CGI 的情况。实际上,图像很少通过配置为 CGI 的 LUT 显示。但 VRML 语言源自 CGI,历史上合成计算机图形中的阴影处理是在线性光域中进行的。(在非线性域中进行阴影处理尚未完全理解。)VRML 最好被视为源自草图中的计算机图形一列。(译者注:VRML 是一种专为万维网而设计的三维图像置标语言。全称是虚拟现实建模语言,是由 VRML 协会设计的。VRML 标准中既定义了描述三维模型的编码格式,也定义了描述交互或脚本的编码及行为模式。VRML 协会现已更名为 Web3D 联盟,VRML 标准现在也已经升级为 X3D 标准。)
Color management 色彩管理
Work is underway to implement facilities in graphics systems to allow device-independent specification of color. Users and applications will be able to specify colors, based on the CIE standards, without concern for gamma correction. Color image files will be tagged with their transfer functions (along with other color parameters). When this transition is complete, it will be much easier to obtain color matching across different graphics libraries and different hardware.
目前正在进行的工作致力于在图形系统中实现设备无关的颜色指定功能。用户和应用程序将能够基于 CIE 标准指定颜色,而无需担心伽马校正。彩色图像文件将标注其转换函数和其他颜色参数。当这一转变完成后,在不同的图形库和硬件之间实现颜色匹配将变得更加容易。
However, these developments will not render gamma irrelevant. Proper use of transfer functions will remain necessary in order to code images in a perceptual manner, so as to achieve maximum performance from a reasonable number of bits per component – 8, say! Also, it will take a long time for this technology to be deployed.
然而,这些发展并不会使伽马失去作用。为了以感知方式编码图像,并从每个分量的合理位数(例如 8 位)中获得最佳性能,仍然需要正确使用转换函数。此外,这项技术的全面部署还需要很长时间。
In the meantime, if you are a programmer, you can take the following steps:
与此同时,如果你是程序员,可以采取以下步骤:
Use gamma-corrected R’G’B’ representations whenever you can. An image coded with gamma correction has good perceptual uniformity, resulting in an image with much higher quality than one coded as 8-bit luminance (or tristimulus) values.
尽可能使用经过伽马校正的 R’G’B’ 表示。经过伽马校正的图像具有良好的感知均匀性,质量远高于仅使用 8 位光亮度(或三刺激值)编码的图像。
When you exchange images either in truecolor or pseudocolor form, code R’G’B’ color values using the Rec. 709 transfer function.
在以真彩色或伪彩色形式交换图像时,使用 Rec. 709 转换函数编码 R’G’B’ 颜色值。
In the absence of reliable information about your monitor, display pictures assuming a monitor gamma value of 2.5.
在缺乏可靠的显示器信息时,假设显示器的伽马值为 2.5 进行显示。
If you are a user, you can take these steps:
如果你是用户,可以采取以下步骤:
Establish good viewing conditions. If you are using a CRT display, you will get better image quality if your overall ambient illumination is reduced.
建立良好的观看条件。如果你使用的是 CRT 显示器,降低整体环境照明将提高图像质量。
Ensure that your monitor’s BLACK LEVEL (or BRIGHTNESS) control is set to correctly reproduce black elements on the screen. Consult my note “BRIGHTNESS” and “CONTRAST” controls, available on the Internet.
确保显示器的“黑电平”’(BLACK LEVEL)或“视亮度”(BRIGHTNESS)控制的设置是正确的,以准确再现屏幕上的黑色元素。参阅我在互联网上关于“亮度”和“对比度”控制的说明。
Demand, from your hardware and software developers and vendors, that they document how they handle transfer functions.
要求你的硬件和软件开发人员及供应商记录他们是如何处理转换函数的。
- 1.See Olson, Thor, “Behind Gamma’s Disguise,” in SMPTE Journal, v. 104, p. 452 (June 1995). ↩
- 2.Berns, Roy S., Ricardo J. Motta, and M.E. Gorzynski, “CRT Colorimetry: Part 1, Theory and Practice; Part 2, Metrology,” in Color Research and Application, v. 18, 299–325 (1993). ↩
- 3.Publication CIE No 15.2, Colorimetry, Second Edition. (Vienna: Central Bureau of the Commission Internationale de L’Éclairage, 1986) ↩
- 4.Stokes, Mike, Mark D. Fairchild, and Roy S. Berns, “Precision requirements for digital color reproduction,” in ACM Transactions on Graphics, v. 11, n. 4 (Oct. 1992), 406–422. ↩
- 5.Poynton, Charles, A Technical Introduction to Digital Video (New York: Wiley, 1996). ↩
- 6.Poynton, Charles, “Luminance, luma, and the migration to DTV,” presented at 32nd SMPTE Advanced Motion Imaging Conference, Toronto (Feb. 6, 1998). ↩
- 7.Apple Computer, Inc., Inside Macintosh (Reading, Mass.: Addison-Wesley-Longman, 1992). 27 volumes. ↩
- 8.Poynton, Charles, A Technical Introduction to Digital Video (New York: Wiley, 1996). ↩
- 9.Gille, J.L., J.O. Larimer, and J. Luszcz, “Error diffusion using the ‘web-safe’ colors: how good is it across platforms?”, in Rogowitz, B.E. and T.N. Pappas (eds.), Human Vision and Electronic Imaging III, Proceedings of SPIE, Volume 3299, 368–375 (Bellingham, Wash.: SPIE, 1998). ↩
转载请注明来源。欢迎留言评论,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。