Theory of Brighter and Bigger 3.0

1. Overview

This paper describes the color transformation that the app "Brighter and Bigger" 3.0 applies to improve the legibility of an image. The framework of this paper is a reorganization, for version 3.0, of the mathematical expressions in the appendix of the README of version 2.0 of the same app [1]. The essential point is that only the lightness is changed while the chromaticity is preserved. Because only the lightness is manipulated, the hue does not change, and only the difference between light and dark is emphasized.

1-1. Assumptions

The following are assumed throughout this paper.

  1. 1. White point: D65, (x,y)=(0.3127, 0.3290)(x,y)=(0.3127,\,0.3290) (the defined value in the sRGB and Display P3 standards [2][3][4]). It is common to all conversions.
  1. 2. Observer: the CIE 1931 2° standard observer [5] (the definition of XYZ [6][7]).
  1. 3. Color spaces: the input and the display are each either sRGB [2] or Display P3 [3][4]. The two share the same transfer function and differ only in the primaries (§2, §3).
  1. 4. Quantization: 8 bits (00 to 255255). The encoded value is treated as a real number in [0,1][0,1] obtained by dividing the pixel value by 255255.
  1. 5. Chromatic adaptation: since the white points of the input and the display are both D65, no chromatic adaptation transform is applied.
  1. 6. Lightness and chromaticity: the lightness is the L∗L^{*} of CIELUV, and the chromaticity is u′, v′u',\,v' of the CIE 1976 UCS diagram [6][7].

1-2. Notation

  • R, G, BR,\,G,\,B: the components of linear RGB, taken in 0≤value≤10\le\text{value}\le 1 with white equal to 11. X, Y, ZX,\,Y,\,Z: the components of XYZ (YY is 11 for white).
  • VV: the encoded value (0≤V≤10\le V\le 1). xx: the linear value (0≤x≤10\le x\le 1). The chromaticity coordinates (x, y)(x,\,y) use the same letter as the linear value xx, but in §3 and §4 they denote chromaticity coordinates.
  • MM: the RGB → XYZ conversion matrix. M−1M^{-1}: the XYZ → RGB conversion matrix.
  • u′, v′u',\,v': the chromaticity coordinates of the CIE 1976 UCS diagram.
  • L∗L^{*}: the lightness, expressed on the scale 0≤L∗≤10\le L^{*}\le 1, which is the CIE definition (00 to 100100) divided by 100100. Thus "L∗=0.5L^{*}=0.5" corresponds to CIE L∗=50L^{*}=50.
  • The lightness at each stage is denoted as follows: L∗L^{*} for the input (the camera image), Lb∗L^{*}_{\mathrm{b}} after Brighter, Lc∗L^{*}_{\mathrm{c}} after Clearer, and Lr∗L^{*}_{\mathrm{r}} after Brightness Reverse. In each section the lightness before the transform and the lightness after the transform are written with these symbols. When the reversal is not applied, Lr∗=Lc∗L^{*}_{\mathrm{r}}=L^{*}_{\mathrm{c}}.
  • bb: the brightness parameter (−0.25≤b≤0.25-0.25\le b\le 0.25). cc: the contrast parameter (0≤c≤10\le c\le 1).

1-3. Flow of the processing

For each pixel of the image, the processing is applied in the following order.

encoded RGB ──(§2) decoding──▶ linear RGB ──(§3) matrix──▶ XYZ ──(§4)──▶ u′v′ and L*
L* ──(§5) Brighter ──▶ L*_b ──(§6) Clearer ──▶ L*_c ──(§7) Brightness Reverse ──▶ L*_r
u′v′ ──(§8) Monochrome Mode: mix the u′v′ of a light and a dark color by L*_r ──▶ u′v′
(L*_r, u′, v′) ──(inverse of §4)──▶ XYZ ──(inverse of §3)──▶ linear RGB ──(encoding of §2)──▶ encoded RGB

The Tilted Angle Correction (§9) gives the correspondence between points on the screen and points on the image, independently of the color computation above.

2. Transfer functions (gamma)

The relation between the encoded value VV (0≤V≤10\le V\le 1; for 8 bits, pixel value255\frac{\text{pixel value}}{255}) and the linear value xx (0≤x≤10\le x\le 1) is defined as the transfer function [8]. The sRGB function of IEC 61966-2-1 [2] is used.

Decoding (encoded value to linear value):

x={V12.92(V≤0.04045)(V+0.0551.055)2.4(V>0.04045)(1)x=\begin{cases} \dfrac{V}{12.92} & (V\le 0.04045)\\[3mm] \left(\dfrac{V+0.055}{1.055}\right)^{2.4} & (V>0.04045) \end{cases} \tag{1}

Encoding (linear value to encoded value):

V={12.92 x(x≤0.0031308)1.055 x12.4−0.055(x>0.0031308)(2)V=\begin{cases} 12.92\,x & (x\le 0.0031308)\\[1mm] 1.055\,x^{\frac{1}{2.4}}-0.055 & (x>0.0031308) \end{cases} \tag{2}

The two expressions are continuous at V=0.04045V=0.04045 (x=0.0031308x=0.0031308), since 0.0404512.92=0.0031308\frac{0.04045}{12.92}=0.0031308.

The transfer function of Display P3 is identical to that of sRGB.

Figure 1: Decoding and encoding functions of sRGB
Figure 1: Decoding and encoding functions of sRGB. The decoding function x(V)x(V) and its inverse, the encoding function V(x)V(x), are shown in a single figure, with the encoded value VV (00 to 11) on the horizontal axis and the linear value xx (00 to 11) on the vertical axis. An enlarged view of V=0V=0 to 0.10.1 is added so that the connection between the linear segment in dark regions (V≤0.04045V\le 0.04045) and the power-law part above it can be seen.

Before encoding, values that have become negative outside the color gamut are replaced by 00 (because a power of a negative number is undefined). Both the decoded and the encoded results are confined to the range 00 to 11.

3. Conversion between RGB and XYZ

Let the linear RGB be the column vector (R,G,B)T(R,G,B)^{\mathsf T}, with the white point D65. The conversion matrices are derived from the chromaticities of the primaries and the white point as follows [7][8].

3-1. Derivation from the primaries and the white point

Let (xi,yi)(x_i,y_i) be the chromaticity of primary ii (i=R,G,Bi=\mathrm{R},\mathrm{G},\mathrm{B}), and define its direction vector

pi=(xiyi11−xi−yiyi)(3)\mathbf{p}_i=\begin{pmatrix} \dfrac{x_i}{y_i}\\[3mm] 1\\[1mm] \dfrac{1-x_i-y_i}{y_i} \end{pmatrix} \tag{3}

Let P=[pR pG pB]P=[\mathbf{p}_{\mathrm R}\ \mathbf{p}_{\mathrm G}\ \mathbf{p}_{\mathrm B}] be the matrix having these vectors as columns, and let W\mathbf{W} be the vector of the same form for the chromaticity (xw,yw)(x_w,y_w) of the white point. The condition that white (R=G=B=1R=G=B=1) is mapped to W\mathbf{W}, namely PS=WP\mathbf{S}=\mathbf{W}, determines the strength coefficients of the primaries, S=P−1W\mathbf{S}=P^{-1}\mathbf{W}. The RGB → XYZ matrix is then

M=P diag(S)(4)M=P\,\mathrm{diag}(\mathbf{S}) \tag{4}

with which white has Y=1Y=1. The XYZ → RGB matrix is the exact inverse M−1M^{-1} of MM.

3-2. sRGB

The chromaticities of the primaries are R(0.64, 0.33)(0.64,\,0.33), G(0.30, 0.60)(0.30,\,0.60), B(0.15, 0.06)(0.15,\,0.06), and the white point is D65 with (x,y)=(0.3127, 0.3290)(x,y)=(0.3127,\,0.3290) (IEC 61966-2-1 [2]). By §3-1, the values derived in double precision are, to seven digits,

(XYZ)=(0.41239080.35758430.18048080.21263900.71516870.07219230.01933080.11919480.9505322)(RGB)(5)\begin{pmatrix}X\\Y\\Z\end{pmatrix}= \begin{pmatrix} 0.4123908 & 0.3575843 & 0.1804808\\ 0.2126390 & 0.7151687 & 0.0721923\\ 0.0193308 & 0.1191948 & 0.9505322 \end{pmatrix} \begin{pmatrix}R\\G\\B\end{pmatrix} \tag{5}
(RGB)=(−3.2409699−1.5373832−0.4986108−0.9692436−1.8759675−0.0415551−0.0556301−0.2039770−1.0569715)(XYZ)(6)\begin{pmatrix}R\\G\\B\end{pmatrix}= \begin{pmatrix} \phantom{-}3.2409699 & -1.5373832 & -0.4986108\\ -0.9692436 & \phantom{-}1.8759675 & \phantom{-}0.0415551\\ \phantom{-}0.0556301 & -0.2039770 & \phantom{-}1.0569715 \end{pmatrix} \begin{pmatrix}X\\Y\\Z\end{pmatrix} \tag{6}

The forward matrix given in the standard [2] to four decimal places (Eq. (7)) coincides with the derived values rounded to four digits.

(0.41240.35760.18050.21260.71520.07220.01930.11920.9505)(7)\begin{pmatrix} 0.4124 & 0.3576 & 0.1805\\ 0.2126 & 0.7152 & 0.0722\\ 0.0193 & 0.1192 & 0.9505 \end{pmatrix} \tag{7}

The inverse matrix of the standard to four digits (Eq. (8)) is the rounded inverse of the rounded forward matrix, and therefore differs from the inverse of the derived matrix above in the fourth digit.

(−3.2406−1.5372−0.4986−0.9689−1.8758−0.0415−0.0557−0.2040−1.0570)(8)\begin{pmatrix} \phantom{-}3.2406 & -1.5372 & -0.4986\\ -0.9689 & \phantom{-}1.8758 & \phantom{-}0.0415\\ \phantom{-}0.0557 & -0.2040 & \phantom{-}1.0570 \end{pmatrix} \tag{8}

3-3. Display P3

The chromaticities of the primaries are R(0.680, 0.320)(0.680,\,0.320), G(0.265, 0.690)(0.265,\,0.690), B(0.150, 0.060)(0.150,\,0.060), and the white point is D65 with (0.3127, 0.3290)(0.3127,\,0.3290) (SMPTE EG 432-1 [3]; Apple's definition [4]). By §3-1 one obtains likewise

(XYZ)=(0.48657090.26566770.19821730.22897460.69173850.07928690.00000000.04511341.0439444)(RGB)(9)\begin{pmatrix}X\\Y\\Z\end{pmatrix}= \begin{pmatrix} 0.4865709 & 0.2656677 & 0.1982173\\ 0.2289746 & 0.6917385 & 0.0792869\\ 0.0000000 & 0.0451134 & 1.0439444 \end{pmatrix} \begin{pmatrix}R\\G\\B\end{pmatrix} \tag{9}
(RGB)=(−2.4934969−0.9313836−0.4027108−0.8294890−1.7626641−0.0236247−0.0358458−0.0761724−0.9568845)(XYZ)(10)\begin{pmatrix}R\\G\\B\end{pmatrix}= \begin{pmatrix} \phantom{-}2.4934969 & -0.9313836 & -0.4027108\\ -0.8294890 & \phantom{-}1.7626641 & \phantom{-}0.0236247\\ \phantom{-}0.0358458 & -0.0761724 & \phantom{-}0.9568845 \end{pmatrix} \begin{pmatrix}X\\Y\\Z\end{pmatrix} \tag{10}

3-4. Exchanging color spaces

XYZ does not depend on the color space. Therefore, even when the input is sRGB and the output is Display P3, u′u', v′v' and L∗L^{*} take the same values on XYZ, and the same color keeps the same appearance while the wide gamut of P3 can be represented.

4. XYZ and CIELUV

4-1. Chromaticity u′, v′u',\,v'

The chromaticity of the CIE 1976 UCS diagram is given by [6][7]

u′=4XX+15Y+3Z,v′=9YX+15Y+3Z(11)u'=\frac{4X}{X+15Y+3Z},\qquad v'=\frac{9Y}{X+15Y+3Z} \tag{11}

In terms of the xyxy chromaticity,

u′=4x−2x+12y+3,v′=9y−2x+12y+3(12)u'=\frac{4x}{-2x+12y+3},\qquad v'=\frac{9y}{-2x+12y+3} \tag{12}

For X=Y=Z=0X=Y=Z=0 (black) the denominator vanishes, so the value of the D65 white, (un′, vn′)≈(0.1978, 0.4683)(u'_n,\,v'_n)\approx(0.1978,\,0.4683), is used.

4-2. Lightness L∗L^{*}

The CIE 1976 lightness (on the scale 0≤L∗≤10\le L^{*}\le 1) is given by [6][7]

L∗={9.033 Y(Y≤0.008856)1.16 Y13−0.16(Y>0.008856)(13)L^{*}=\begin{cases} 9.033\,Y & (Y\le 0.008856)\\[1mm] 1.16\,Y^{\frac{1}{3}}-0.16 & (Y>0.008856) \end{cases} \tag{13}

Here 9.0339.033 is κ100\frac{\kappa}{100} with κ=(293)3≈903.3\kappa=\left(\frac{29}{3}\right)^{3}\approx 903.3, and 0.0088560.008856 corresponds to ε=(629)3\varepsilon=\left(\frac{6}{29}\right)^{3}. This is the CIE definition 116 f ⁣(YYn)−16116\,f\!\left(\frac{Y}{Y_n}\right)-16 divided by 100100, and the two expressions are continuous at the boundary Y=εY=\varepsilon, where L∗=0.0800L^{*}=0.0800.

Figure 2: Relation between luminance Y and lightness L*
Figure 2: Relation between luminance YY and lightness L∗L^{*}. The curve defined above is plotted with YY (00 to 11) on the horizontal axis and L∗L^{*} (00 to 11) on the vertical axis, together with the pure cube-root expression 1.16 Y13−0.161.16\,Y^{\frac{1}{3}}-0.16 to show the difference in dark regions.

4-3. Inverse conversion

XYZ is obtained from the lightness after the transform, Lr∗L^{*}_{\mathrm{r}}, and the chromaticity (u′,v′)(u',v') by

Y={Lr∗9.033(Lr∗≤0.08)(Lr∗+0.161.16)3(Lr∗>0.08)(14)Y=\begin{cases} \dfrac{L^{*}_{\mathrm{r}}}{9.033} & (L^{*}_{\mathrm{r}}\le 0.08)\\[3mm] \left(\dfrac{L^{*}_{\mathrm{r}}+0.16}{1.16}\right)^{3} & (L^{*}_{\mathrm{r}}>0.08) \end{cases} \tag{14}

where 19.033≈0.11071\frac{1}{9.033}\approx 0.11071.

X=Y 9u′4v′,Z=Y 12−3u′−20v′4v′(15)X=Y\,\frac{9u'}{4v'},\qquad Z=Y\,\frac{12-3u'-20v'}{4v'} \tag{15}

The boundary Lr∗=0.08L^{*}_{\mathrm{r}}=0.08 corresponds to CIE L∗=8L^{*}=8 (=κε100=\frac{\kappa\varepsilon}{100}). Eq. (15) is the definition of u′u' and v′v' in Eq. (11) solved for XX and ZZ; multiplication by YY changes the brightness while the chromaticity stays unchanged.

5. Brighter

The value bb is added to the lightness before the transform, L∗L^{*}, to give the lightness after the transform, Lb∗L^{*}_{\mathrm{b}}.

Lb∗=L∗+b(−0.25≤b≤0.25)(16)L^{*}_{\mathrm{b}}=L^{*}+b\qquad(-0.25\le b\le 0.25) \tag{16}

A positive bb makes the whole image brighter and a negative bb makes it darker. The chromaticity is not changed.

Figure 3: Lines of Brighter
Figure 3: Lines of Brighter. Eleven straight lines for b=−0.25, −0.20, …, +0.25b=-0.25,\,-0.20,\,\dots,\,+0.25 (dial positions −5-5 to +5+5) are overlaid, with the lightness before the transform, L∗L^{*} (00 to 11), on the horizontal axis and the lightness after the transform, Lb∗L^{*}_{\mathrm{b}} (00 to 11), on the vertical axis, with the same axes, size, and color order as the figure of Clearer (Figure 4). The lines are parallel with slope 11, and move upward for positive bb and downward for negative bb. Lb∗L^{*}_{\mathrm{b}} extends beyond [0,1][0,1], but the part outside the frame is not shown.

6. Clearer

A logistic function normalized so that both ends coincide with 00 and 11 is applied to the lightness before the transform, Lb∗L^{*}_{\mathrm{b}}, to give the lightness after the transform, Lc∗L^{*}_{\mathrm{c}}.

t0=20c+1(0≤c≤1)(17)t_0=20c+1\qquad(0\le c\le 1) \tag{17}
y0=11+et0,y1=11+e(1−2Lb∗) t0(18)y_0=\frac{1}{1+e^{t_0}},\qquad y_1=\frac{1}{1+e^{(1-2L^{*}_{\mathrm{b}})\,t_0}} \tag{18}
Lc∗=y1−y01−2y0(19)L^{*}_{\mathrm{c}}=\frac{y_1-y_0}{1-2y_0} \tag{19}

Properties

Figure 4: Curves of Clearer
Figure 4: Curves of Clearer. Eleven curves for c=0.0, 0.1, …, 1.0c=0.0,\,0.1,\,\dots,\,1.0 are overlaid, with the lightness before the transform, Lb∗L^{*}_{\mathrm{b}} (00 to 11), on the horizontal axis and the lightness after the transform, Lc∗L^{*}_{\mathrm{c}} (00 to 11), on the vertical axis. The point symmetry about (0.5, 0.5)(0.5,\,0.5) and the increase of the central slope with cc can be read from the figure.
Figure 5: Combination of Brighter and Clearer
Figure 5: Combination of Brighter and Clearer. Eleven curves Lc∗=σt0(L∗+b)L^{*}_{\mathrm{c}}=\sigma_{t_0}(L^{*}+b) for b=−0.25, −0.20, …, +0.25b=-0.25,\,-0.20,\,\dots,\,+0.25 are overlaid with Clearer fixed at c=0.5c=0.5 (t0=11t_0=11), with the input lightness L∗L^{*} (00 to 11) on the horizontal axis and the lightness after the transform, Lc∗L^{*}_{\mathrm{c}} (00 to 11), on the vertical axis. Here σt0\sigma_{t_0} is the normalized logistic function of this section. The axes, size, and color order are the same as in the figure of Brighter (Figure 3) and the figure of Clearer (Figure 4). Brighter translates the curve along the horizontal axis, and Clearer determines the steepness of the curve.
  • End points and center: Lc∗=0L^{*}_{\mathrm{c}}=0 at Lb∗=0L^{*}_{\mathrm{b}}=0, Lc∗=1L^{*}_{\mathrm{c}}=1 at Lb∗=1L^{*}_{\mathrm{b}}=1, and Lc∗=0.5L^{*}_{\mathrm{c}}=0.5 at Lb∗=0.5L^{*}_{\mathrm{b}}=0.5. The curve is point-symmetric about the point (0.5, 0.5)(0.5,\,0.5). The denominator 1−2y01-2y_0 is the normalization that fits both ends to 00 and 11.
  • Slope: The slope at Lb∗=0.5L^{*}_{\mathrm{b}}=0.5 is

    dLc∗dLb∗=t02 (1−2y0)(20)\frac{dL^{*}_{\mathrm{c}}}{dL^{*}_{\mathrm{b}}}=\frac{t_0}{2\,(1-2y_0)} \tag{20}

    which is about 1.081.08 for c=0c=0, 5.55.5 for c=0.5c=0.5, and 10.510.5 for c=1c=1. The larger cc is, the steeper the curve is near the center: the dark side becomes darker and the light side becomes lighter, so that the difference between light and dark is emphasized.

  • Inverse function: Put y=Lc∗ (1−2y0)+y0y=L^{*}_{\mathrm{c}}\,(1-2y_0)+y_0. Then

    Lb∗=12(1−1t0ln⁡ ⁣(1y−1))(21)L^{*}_{\mathrm{b}}=\frac{1}{2}\left(1-\frac{1}{t_0}\ln\!\left(\frac{1}{y}-1\right)\right) \tag{21}
  • Even for c=0c=0 the map is not the identity but a gentle S-shaped curve with t0=1t_0=1. The maximum deviation from the identity is −0.0153-0.0153, at Lb∗=0.22L^{*}_{\mathrm{b}}=0.22.
  • Combination with Brighter: When bb is added, the center of the S-shaped curve (the point where Lc∗=0.5L^{*}_{\mathrm{c}}=0.5) moves to L∗=0.5−bL^{*}=0.5-b.
  • Domain: For b≠0b\ne 0, Lb∗L^{*}_{\mathrm{b}} may extend outside [0,1][0,1]. In that case Lc∗L^{*}_{\mathrm{c}} may also extend outside [0,1][0,1] (for example, for c=0c=0 and b=±0.25b=\pm 0.25, Lc∗L^{*}_{\mathrm{c}} ranges from −0.187-0.187 to 1.1871.187). The larger cc is, the closer to 00 or 11 the outlying part falls asymptotically. Clipping to the displayable range is performed at the encoding stage of §2.

Origin

This S-shaped curve was inspired by the compression of the cone response. That the CIE lightness is expressed as the cube root of the intensity is known as a fit of Stevens' power law [9]. In contrast, the compression of the cone response is expressed by the following fractional function.

R=InIn+σn(22)R=\frac{I^{n}}{I^{n}+\sigma^{n}} \tag{22}

This is a function of the Naka–Rushton type [10], which has also been fitted to measurements of primate cones [11]. Similar compression is used in the compression stages of the color appearance models CIECAM02 [12] and CAM16 [13] (see [14] for an exposition). Plotted against the logarithm of the intensity, the fractional function draws the same S-shaped curve as the logistic function. The logistic function was adopted because the slope can be controlled by a single parameter t0t_0 and because the normalization that fits both ends to 00 and 11 is simple.

7. Brightness Reverse

From the lightness before the transform, Lc∗L^{*}_{\mathrm{c}}, the lightness after the transform, Lr∗L^{*}_{\mathrm{r}}, is defined by

Lr∗=1−Lc∗(23)L^{*}_{\mathrm{r}}=1-L^{*}_{\mathrm{c}} \tag{23}

When the reversal is not applied, Lr∗=Lc∗L^{*}_{\mathrm{r}}=L^{*}_{\mathrm{c}}. The reversal is applied to Lc∗L^{*}_{\mathrm{c}}. Since the S-shaped curve is point-symmetric about (0.5, 0.5)(0.5,\,0.5), exchanging the order of the reversal and Clearer does not change the result when b=0b=0. When b≠0b\ne 0, the result depends on the order.

8. Monochrome Mode

In Monochrome Mode, the chromaticity of the original pixel is discarded and replaced with a chromaticity obtained by mixing the u′v′u'v' of a light color and a dark color by Lr∗L^{*}_{\mathrm{r}}. The light color L and the dark color D are specified by sRGB values, and their chromaticities obtained by §4-1 are denoted (uL′, vL′)(u'_{\mathrm L},\,v'_{\mathrm L}) and (uD′, vD′)(u'_{\mathrm D},\,v'_{\mathrm D}).

(u′v′)=(uD′vD′)+Lr∗[(uL′vL′)−(uD′vD′)](24)\begin{pmatrix}u'\\v'\end{pmatrix}= \begin{pmatrix}u'_{\mathrm D}\\v'_{\mathrm D}\end{pmatrix} +L^{*}_{\mathrm{r}}\left[ \begin{pmatrix}u'_{\mathrm L}\\v'_{\mathrm L}\end{pmatrix}- \begin{pmatrix}u'_{\mathrm D}\\v'_{\mathrm D}\end{pmatrix} \right] \tag{24}
  • When L = D, the mode is one-color: the chromaticity is constant and only the brightness varies. When L ≠ D, the mode is two-color: the dark side approaches the tint of D and the light side that of L.
  • The mixing is a linear interpolation on the u′v′u'v' plane, not in L∗L^{*}. The result lies on the line segment connecting the two points. Since the triangle of the color gamut is convex, the mixed chromaticity does not leave the gamut for 0≤Lr∗≤10\le L^{*}_{\mathrm{r}}\le 1.
  • When the light or dark color is black (XYZ all zero), the chromaticity of the D65 white is used, as in §4-1.
Figure 6: Locus of the mixed chromaticity on the chromaticity diagram
Figure 6: Locus of the mixed chromaticity on the chromaticity diagram. The triangles of the sRGB and Display P3 gamuts are drawn on the u′v′u'v' plane, together with the two points of the light and dark colors and the line segment corresponding to Lr∗L^{*}_{\mathrm{r}} from 00 to 11. The figure confirms that the segment lies inside the triangle.

Clipping at the gamut boundary

When YY is increased with the chromaticity fixed, there is a point at which the linear RGB values exceed 11 while the chromaticity is unchanged. The excess is clipped to 11 by the encoding, and the tint moves toward white. For a color of chromaticity (u′,v′)(u',v'), let μ\mu be the largest linear RGB component per unit luminance (Y=1Y=1). Clipping begins at the luminance Y=1μY=\frac{1}{\mu}, that is,

Lclip∗=L∗ ⁣(Y=1μ)(25)L^{*}_{\mathrm{clip}}=L^{*}\!\left(Y=\frac{1}{\mu}\right) \tag{25}

This threshold depends on the color. Examples with sRGB linear RGB are given below.

ColorRGBLclip∗L^{*}_{\mathrm{clip}}Largest component at Lr∗=1L^{*}_{\mathrm{r}}=1 (linear)
White (achromatic)FFFFFFno clipping1.00
YellowFFFF000.9721.08
Cyan00FFFF0.9121.27
Green00FF000.8781.40
Sepia6A4A2B0.7991.77

The larger the largest component μ\mu per unit luminance, the lower the threshold. For example, sepia has a small largest component, but when converted to unit luminance its μ\mu is large, so its threshold is as low as 0.7990.799. In the two-color mode, the same threshold is determined for each mixed chromaticity.

Figure 7: Clipping thresholds for each color
Figure 7: Clipping thresholds for each color. For each color in the table, the largest linear component is plotted against Lr∗L^{*}_{\mathrm{r}} (horizontal axis), and the point where it reaches 11, namely Lclip∗L^{*}_{\mathrm{clip}}, is marked.

9. Tilted Angle Correction (projection transform)

A sheet of paper photographed from an oblique direction is corrected to look as if viewed from directly above. The correction is represented by a single projective transformation HH that maps a point on the corrected screen to a point on the image.

9-1. Inverse of the perspective

The paper is assumed to be a plane whose center is crossed by the optical axis of the camera. The plane is tilted about a horizontal axis by a tilt angle θ\theta (0≤θ<90∘0\le\theta<90^{\circ}), with the upper part of the paper farther away. Taking the focal length as the unit of distance, let the distance from the camera to the center of the paper be 11. A point (xp, yp)(x_p,\,y_p) on the paper lies at (xp, ypcos⁡θ, 1+ypsin⁡θ)(x_p,\ y_p\cos\theta,\ 1+y_p\sin\theta) in three dimensions, and its image coordinates (Ξ, Υ)(\Xi,\,\Upsilon) (in units of the focal length) are

Ξ=xp1+ypsin⁡θ,Υ=ypcos⁡θ1+ypsin⁡θ(26)\Xi=\frac{x_p}{1+y_p\sin\theta},\qquad \Upsilon=\frac{y_p\cos\theta}{1+y_p\sin\theta} \tag{26}

The normalized image coordinates (u,v)(u,v) (with the edges of the image at ±1\pm 1) are related to these through the width sxs_x and the height sys_y of the image and the focal length ff (in the same unit) by

Ξ=ξ u,Υ=η v,ξ=sx2f,η=sy2f(27)\Xi=\xi\,u,\qquad \Upsilon=\eta\,v,\qquad \xi=\frac{s_x}{2f},\qquad \eta=\frac{s_y}{2f} \tag{27}

Here ξ\xi and η\eta are the tangents of the half angles of view, and η\eta is the one in the vertical direction of the screen.

Let the normalized coordinates (X,Y)(X,Y) of the corrected screen be proportional to the coordinates on the paper, xp=ξXx_p=\xi X and yp=ηYy_p=\eta Y. Substituting these into Eq. (26) and solving for uu and vv gives the map from a point of the corrected screen to a point of the image.

u=X1+ηsin⁡θ Y,v=Ycos⁡θ1+ηsin⁡θ Y(28)u=\frac{X}{1+\eta\sin\theta\,Y},\qquad v=\frac{Y\cos\theta}{1+\eta\sin\theta\,Y} \tag{28}

This is the projective transformation, in homogeneous coordinates, given by the following 3×33\times 3 matrix Q−1Q^{-1}.

Q−1=(1000cos⁡θ00ηsin⁡θ1)(29)Q^{-1}=\begin{pmatrix} 1 & 0 & 0\\ 0 & \cos\theta & 0\\ 0 & \eta\sin\theta & 1 \end{pmatrix} \tag{29}

Applying Q−1Q^{-1} to (X,Y,1)T(X,Y,1)^{\mathsf T} gives (u′, v′, w)T(u',\,v',\,w)^{\mathsf T}, and (u,v)=(u′w,v′w)(u,v)=\left(\frac{u'}{w},\frac{v'}{w}\right). The case where the near side is the bottom side is shown. When the near side is the right, top, or left side, the matrix of the same form with the axes and signs exchanged is used.

The distance to the paper is not needed. Changing the distance only changes the overall scale of the corrected image.

The aspect ratio is preserved. The physical coordinates of the corrected screen, given the aspect ratio ξ:η\xi:\eta of the image, are (ξX, ηY)=(xp, yp)(\xi X,\ \eta Y)=(x_p,\ y_p). That is, the corrected image is the coordinates of the plane of the paper itself and is similar to it. Therefore ratios of lengths and angles are preserved, and a square sheet of paper is imaged as a square. This is the metric rectification of Hartley and Zisserman [15] (Section 2.7), applied to the case where the tilt is restricted to a horizontal axis.

9-2. Magnification that fills the margins

To keep the four corners of the corrected screen inside the image, the coordinates of the screen must be scaled by 1m\frac{1}{m}. From the condition that the near corners (±1m, −1m)\left(\pm\frac{1}{m},\,-\frac{1}{m}\right) lie inside the image, 1/m1−ηsin⁡θ/m≤1\dfrac{1/m}{1-\eta\sin\theta/m}\le 1, the magnification is

m=1+ηsin⁡θ(30)m=1+\eta\sin\theta \tag{30}

(w>0w>0 is preserved as long as ηsin⁡θ<1\eta\sin\theta<1). The value mm increases with θ\theta, and part of the edge of the image falls outside the screen.

9-3. The overall transformation

The transformation HH from a point on the screen (with coordinates normalized to the range 00 to 11) to a point on the image is the composition of the following maps.

H=T⋅Q−1⋅diag ⁣(1m,1m,1)⋅A−1⋅S(31)H=T\cdot Q^{-1}\cdot\mathrm{diag}\!\left(\tfrac{1}{m},\tfrac{1}{m},1\right)\cdot A^{-1}\cdot S \tag{31}
SymbolMeaningExpression
SSscreen coordinates → NDC (−1-1 to 11)X=2x−1,Y=1−2yX=2x-1,\quad Y=1-2y
A−1A^{-1}inverse of zoom, pan, and horizontal flipX′=±X−2 panxzoom⋅hx,Y′=Y−2 panyzoom⋅hyX'=\dfrac{\pm X-2\,\mathrm{pan}_x}{\mathrm{zoom}\cdot h_x},\quad Y'=\dfrac{Y-2\,\mathrm{pan}_y}{\mathrm{zoom}\cdot h_y}
diag(1m,1m,1)\mathrm{diag}\left(\frac{1}{m},\frac{1}{m},1\right)inverse of the magnification that fills the marginsmm of Eq. (30)
Q−1Q^{-1}inverse of the perspectiveEq. (29)
TTNDC → image coordinatesa linear map (determined by the orientation of the image)

Here zoom\mathrm{zoom} is the magnification, panx\mathrm{pan}_x and pany\mathrm{pan}_y are the shifts, and hxh_x and hyh_y are the ratios that make the image fill the screen (one of them is 11). The transformation from the image to the screen is given by the inverse matrix of HH, which is again a 3×33\times 3 projective transformation.

References

[1] K. Asada, "Brighter and Bigger", README (appendix: mathematical expressions of the Brighter and Clearer theory), GitHub repository asada0/BrighterAndBigger, 2019, MIT License. https://github.com/asada0/BrighterAndBigger

[2] IEC 61966-2-1:1999, Multimedia systems and equipment — Colour measurement and management — Part 2-1: Colour management — Default RGB colour space — sRGB, International Electrotechnical Commission; and Amendment 1:2003 (published 23 January 2003).

[3] SMPTE EG 432-1:2010, Digital Source Processing — Color Processing for D-Cinema, Society of Motion Picture and Television Engineers, 10 November 2010. doi:10.5594/SMPTE.EG432-1.2010

[4] Apple Inc., "Display P3", ICC RGB Color Space Registry, International Color Consortium, version 1.0, 9 February 2022. https://registry.color.org/rgb-registry/displayp3 (accessed 22 October 2026). See also Apple Developer Documentation, CGColorSpace.displayP3, https://developer.apple.com/documentation/coregraphics/cgcolorspace/displayp3 (accessed 22 October 2026).

[5] T. Smith and J. Guild, "The C.I.E. colorimetric standards and their use", Transactions of the Optical Society, vol. 33, no. 3, pp. 73–134, 1931–32. doi:10.1088/1475-4878/33/3/301

[6] CIE 15:2004, Colorimetry, 3rd ed., Commission Internationale de l'Éclairage, 2004, ISBN 978-3-901906-33-6 (since superseded by CIE 015:2018).

[7] G. Wyszecki and W. S. Stiles, Color Science: Concepts and Methods, Quantitative Data and Formulae, 2nd ed., John Wiley & Sons, 1982, ISBN 978-0-471-02106-3.

[8] C. Poynton, Digital Video and HD: Algorithms and Interfaces, 2nd ed., Morgan Kaufmann, 2012, ISBN 978-0-12-391926-7.

[9] S. S. Stevens, "On the psychophysical law", Psychological Review, vol. 64, no. 3, pp. 153–181, 1957. doi:10.1037/h0046162

[10] K. I. Naka and W. A. H. Rushton, "S-potentials from colour units in the retina of fish (Cyprinidae)", The Journal of Physiology, vol. 185, no. 3, pp. 536–555, 1966. doi:10.1113/jphysiol.1966.sp008001

[11] J. M. Valeton and D. van Norren, "Light adaptation of primate cones: An analysis based on extracellular data", Vision Research, vol. 23, no. 12, pp. 1539–1547, 1983. doi:10.1016/0042-6989(83)90167-0

[12] CIE 159:2004, A Colour Appearance Model for Colour Management Systems: CIECAM02, Commission Internationale de l'Éclairage, 2004, ISBN 978-3-901906-29-9.

[13] C. Li, Z. Li, Z. Wang, Y. Xu, M. R. Luo, G. Cui, M. Melgosa, M. H. Brill, and M. Pointer, "Comprehensive color solutions: CAM16, CAT16, and CAM16-UCS", Color Research & Application, vol. 42, no. 6, pp. 703–718, 2017. doi:10.1002/col.22131

[14] M. D. Fairchild, Color Appearance Models, 3rd ed., John Wiley & Sons, 2013, ISBN 978-1-119-96703-3. doi:10.1002/9781118653128

[15] R. Hartley and A. Zisserman, Multiple View Geometry in Computer Vision, 2nd ed., Cambridge University Press, 2003, ISBN 978-0-521-54051-3. doi:10.1017/CBO9780511811685