Theory of Iro no Megane (Chromatic Glass) 3.0

1. Overview

"Chromatic Glass" has three functions, switched with the tab bar at the bottom of the screen.

FunctionWhat it doesSection
Distinguish colorsChanges colors that are hard to tell apart into easier ones, zone by zone (a zone is a range of colors chosen with a slider)§6 (how zones are decided), §7 (how colors are changed)
Find colorsChanges only the colors close to a target color, so that they stand out§8 (target color and range), §7 (how colors are changed)
SimulationOverlays on the image how it looks to a person with the corresponding color vision type, to check the result§9 (shared with Chromatic Vision Simulator 4.0)

Distinguish and Find differ in which colors are changed, and share how they are changed (§7). Both focus on the difference in color that the person finds hard to distinguish. A person of type 1, 2 or 3 has a response of one of the L, M, S cones that differs from other people's, and finds it hard to distinguish two colors that differ only in that cone's response. The app moves colors in a direction different from that difference in cone response, so that colors that are hard to tell apart move to different colors.

In addition, there is a display of the name of the color under the cursor. It works as in Chromatic Vision Simulator 4.0 (§9).

As in the theory of Chromatic Vision Simulator 4.0, this paper gives all equations and constants down to the transfer function, the color space matrices, the cone matrix, the chromaticity diagram and the uniform color spaces, and then describes, with equations, how zones are decided (three methods), how colors are changed, and how Find colors works.

1-1. Assumptions

The following hold throughout this paper.

  1. 1. White point: D65, (x,y)=(0.3127, 0.3290)(x,y)=(0.3127,\,0.3290), (u′,v′)=(0.19783, 0.46832)(u',v')=(0.19783,\,0.46832) (the defined values of sRGB and Display P3 [3][4][5]). It is common to all conversions.
  1. 2. Observer: The XYZ of image colors is for the CIE 1931 2° standard observer [6] (definition of XYZ [7][8]). For the construction of the cone matrix (§4) and for the chromaticity coordinates of the anchor stimuli of the boost method (§7-5), the color matching functions of the CIE 1964 10° supplementary standard observer (X10Y10Z10 system) [7] and their chromaticity coordinates (JIS Z 8701, Appendix Table 2 [9]) are used.
  1. 3. Color space: Input and display are each sRGB [3] or Display P3 [4][5]. They have the same transfer function and differ only in primaries (§2, §3). Numerical values and figures below are for sRGB unless noted.
  1. 4. Quantization: 8 bits (00 to 255255). An encoded value is the pixel value divided by 255255, a real number from 00 to 11.
  1. 5. Chromatic adaptation: Input and display both have the D65 white point, so no chromatic adaptation transform is applied.
  1. 6. Cone space: XYZ is converted to LMS with the same matrix as Chromatic Vision Simulator 4.0 (a matrix that keeps the shape of the Hunt–Pointer–Estévez (HPE) cones, built to match the 10° XYZ and normalized to D65) [9][10][11].
  1. 7. Color vision types: Types 1, 2 and 3 are the types for which the response of the L, M and S cone, respectively, differs from other people's. In calculation they are treated with a dichromat model that has no response from that cone, The simulation strength is a value for showing the intermediate image between the color appearance of the most severe form of dichromacy of each type (100%) and the original image (0%). It does not simulate the color appearance of anomalous trichromacy (mild color vision deficiency) (Simulation, §9).
  1. 8. Display: A changed color is confined to 00–11 of the linear RGB of the display color space and then encoded. When the color space differs between input and display (for example, Display P3 input and sRGB display), the calculations from §4 on are common; only the input and display matrices are replaced.

1-2. Notation

  • R, G, BR,\,G,\,B: components of linear RGB, from 00 to 11, white being 11. X, Y, ZX,\,Y,\,Z: components of XYZ (YY is 11 for white).
  • c\mathbf{c}: color of a pixel (XYZ). Encoded RGB (components VV, 0≤V≤10\le V\le 1) is written cin\mathbf{c}_{\mathrm{in}}, cout\mathbf{c}_{\mathrm{out}}.
  • L, M, SL,\,M,\,S: cone responses (LMS). q=(L,M,S)T\mathbf{q}=(L,M,S)^{\mathsf T}. For D65 white, q=(1,1,1)T\mathbf{q}=(1,1,1)^{\mathsf T}.
  • MM: matrix from linear RGB to XYZ. MLMSM_{\mathrm{LMS}}: matrix from XYZ to LMS.
  • u′,v′u',v': CIE 1976 UCS chromaticity coordinates. L∗,u∗,v∗L^*,u^*,v^*: CIELUV. L,a,bL,a,b: Oklab (the same symbol as the cone response LL, but used only in §5-3 and §6-5).
  • PP: zone position (red primary 00, green primary 11; for type 3, green 00, blue 11). The slider value is s=1−Ps=1-P.
  • ff: change magnitude (00 to 0.50.5). age\mathrm{age}: color rotation (one turn is 00 to 11). ww: zone width, aZa_Z: zone start (slider value). wSw_S: width of the range in Find colors.

1-3. Processing flow

The following is applied to each pixel of the image, in this order.

encoded RGB ──(§2) decode──▶ linear RGB ──(§3, §4) matrices──▶ XYZ, LMS
   Distinguish:  decide pixels inside the zone by the zone position P (§6) ─┐
   Find:         decide pixels near the target by the u′v′ distance (§8)   ─┴▶ selected pixels
selected pixels ──(§7) change in CIELUV, confine to the gamut triangle──▶ changed XYZ
changed XYZ ──(§4) LMS──▶ (overlay of §9 Simulation, if on) ──▶ display linear RGB (clipped to 0–1) ──(§2) encode──▶ encoded RGB

2. Transfer function (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 [12]. The sRGB function of IEC 61966-2-1 [3] is used.

Decoding (from encoded to linear):

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 (from linear to encoded):

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 equations are continuous at V=0.04045V=0.04045 (x=0.0031308x=0.0031308) (0.0404512.92=0.0031308\frac{0.04045}{12.92}=0.0031308). The transfer function of Display P3 is identical to that of sRGB.

Before encoding, values that became negative outside the gamut are replaced by 00 (a power of a negative number is undefined). The results of decoding and encoding are both clipped to 00–11.

3. Conversion between RGB and XYZ

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

3-1. Derivation from primaries and white point

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

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 with these as columns, and W\mathbf{W} the vector of the same form for the white point chromaticity (xw,yw)(x_w,y_w). From the condition PS=WP\mathbf{S}=\mathbf{W} that white (R=G=B=1R=G=B=1) maps to W\mathbf{W}, the strength coefficients of the primaries are S=P−1W\mathbf{S}=P^{-1}\mathbf{W}. The RGB-to-XYZ matrix is then

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

and white has Y=1Y=1. The XYZ-to-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, (x,y)=(0.3127, 0.3290)(x,y)=(0.3127,\,0.3290) (IEC 61966-2-1 [3]). By §3-1, the double-precision derived values to 7 digits are as follows.

(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}

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, (0.3127, 0.3290)(0.3127,\,0.3290) (SMPTE EG 432-1 [4], Apple's definition [5]). By §3-1, likewise:

(XYZ)=(0.48657090.26566770.19821730.22897460.69173850.07928690.00000000.04511341.0439444)(RGB)(7)\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{7}
(RGB)=(−2.4934969−0.9313836−0.4027108−0.8294890−1.7626641−0.0236247−0.0358458−0.0761724−0.9568845)(XYZ)(8)\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{8}

3-4. Replacing the color space

XYZ does not depend on the color space. Therefore, even if the input is sRGB and the display is Display P3, the calculations from the conversion to LMS (§4) on are common, and only the input and display matrices need be replaced. All constants of the calculation (chromaticities of the gamut primaries, constants of the zone) are computed from the primaries and white of the display color space.

4. Conversion from XYZ to LMS

4-1. Cone matrix (a 10° matrix keeping the shape of HPE)

The cone responses q=(L,M,S)T\mathbf{q}=(L,M,S)^{\mathsf T} are given as a linear transform of XYZ. As in Chromatic Vision Simulator 4.0, this paper uses a 3×3 matrix that keeps the shape of the spectral sensitivities of the Hunt–Pointer–Estévez (HPE) cones [10], built from the XYZ of the CIE 1964 10° supplementary standard observer (X10Y10Z10; JIS Z 8701, Appendix Table 2 [9]). The HPE transform is expressed by the following matrix from CIE 1931 XYZ to cone responses (the form normalized to equal-energy white; see [11]).

ME=(−0.389710.68898−0.07868−0.229811.18340−0.04641−0.000000.00000−1.00000)(9)M_{\mathrm{E}}=\begin{pmatrix} \phantom{-}0.38971 & 0.68898 & -0.07868\\ -0.22981 & 1.18340 & \phantom{-}0.04641\\ \phantom{-}0.00000 & 0.00000 & \phantom{-}1.00000 \end{pmatrix} \tag{9}

The matrix MrawM_{\mathrm{raw}} for the 10° observer is found by unweighted least squares over all wavelengths λ\lambda (81 points, 380 to 780 nm at 5 nm steps), so that the 10° color matching functions reproduce the HPE cone sensitivities as well as possible. The 10° color matching functions are xˉ(10)(λ)=(xˉ(10),yˉ(10),zˉ(10))T\bar{\mathbf{x}}^{(10)}(\lambda)=(\bar x^{(10)},\bar y^{(10)},\bar z^{(10)})^{\mathsf T} (CIE 1964 [7]), and the HPE cone sensitivities are ME xˉ(2)(λ)M_{\mathrm{E}}\,\bar{\mathbf{x}}^{(2)}(\lambda), where xˉ(2)(λ)\bar{\mathbf{x}}^{(2)}(\lambda) are the CIE 1931 2° color matching functions. Both sets of values are taken every 5 nm from the 1 nm tables of [13]. The rows are then normalized by dividing by the corresponding component of MrawWM_{\mathrm{raw}}\mathbf{W}, so that the XYZ of the D65 white point (W\mathbf{W}, §3-1) gives L=M=S=1L=M=S=1.

Mraw=arg minM∑λ∥M xˉ(10)(λ)−ME xˉ(2)(λ)∥2,MLMS=diag(n)−1Mraw,n=MrawW(10)\begin{aligned} M_{\mathrm{raw}}&=\mathop{\mathrm{arg\,min}}_{M}\sum_{\lambda}\left\|M\,\bar{\mathbf{x}}^{(10)}(\lambda)-M_{\mathrm{E}}\,\bar{\mathbf{x}}^{(2)}(\lambda)\right\|^{2},\\[2mm] M_{\mathrm{LMS}}&=\mathrm{diag}(\mathbf{n})^{-1}M_{\mathrm{raw}},\qquad \mathbf{n}=M_{\mathrm{raw}}\mathbf{W} \end{aligned} \tag{10}

The values found are as follows, to 5 digits.

MLMS=(−0.47008−0.67928−0.11576−0.18706−1.18397−0.00567−0.05526−0.06666−0.90524)(11)M_{\mathrm{LMS}}=\begin{pmatrix} \phantom{-}0.47008 & \phantom{-}0.67928 & -0.11576\\ -0.18706 & \phantom{-}1.18397 & -0.00567\\ -0.05526 & \phantom{-}0.06666 & \phantom{-}0.90524 \end{pmatrix} \tag{11}

This matrix is not a published standard but an approximation made for Chromatic Vision Simulator 4.0, and the shape of the cones remains that of HPE (the residual of the fit and the treatment of physical differences of 10° cones are described in §4-1 of the theory of Chromatic Vision Simulator 4.0). By this normalization, D65 white maps to q=(1,1,1)T\mathbf{q}=(1,1,1)^{\mathsf T}. The inverse matrix is as follows (7 digits).

MLMS−1=(−1.7487090−1.0155232−0.2172701−0.2767005−0.6836341−0.0396654−0.0863663−0.1123291−1.1150205)(12)M_{\mathrm{LMS}}^{-1}=\begin{pmatrix} \phantom{-}1.7487090 & -1.0155232 & \phantom{-}0.2172701\\ \phantom{-}0.2767005 & \phantom{-}0.6836341 & \phantom{-}0.0396654\\ \phantom{-}0.0863663 & -0.1123291 & \phantom{-}1.1150205 \end{pmatrix} \tag{12}

The columns of this inverse matrix are the colors that stimulate only one kind of cone (the XYZ in the directions where q\mathbf{q} is (1,0,0)T(1,0,0)^{\mathsf T}, (0,1,0)T(0,1,0)^{\mathsf T}, (0,0,1)T(0,0,1)^{\mathsf T}), which become the confusion-line directions e\mathbf{e} of §6.

4-2. Conversion between linear RGB and LMS

The conversion from linear RGB to LMS is given by the product of MM of Eq. (4) and MLMSM_{\mathrm{LMS}} of Eq. (11).

q=MLMS M(RGB),(RGB)=(MLMS M)−1q(13)\mathbf{q}=M_{\mathrm{LMS}}\,M\begin{pmatrix}R\\G\\B\end{pmatrix},\qquad \begin{pmatrix}R\\G\\B\end{pmatrix}=\left(M_{\mathrm{LMS}}\,M\right)^{-1}\mathbf{q} \tag{13}

When input and display are sRGB, the 7-digit values are:

MLMSM=(0.33606200.64009540.02384260.17450560.77916950.04632490.00888630.13581410.8552996),(MLMSM)−1=(−5.1990556−4.2862792−0.0872236−1.1722550−2.2620970−0.0898419−0.1321271−0.3146679−1.1825408)(14)\begin{aligned} M_{\mathrm{LMS}}M&=\begin{pmatrix} 0.3360620 & 0.6400954 & 0.0238426\\ 0.1745056 & 0.7791695 & 0.0463249\\ 0.0088863 & 0.1358141 & 0.8552996 \end{pmatrix},\\[3mm] \left(M_{\mathrm{LMS}}M\right)^{-1}&=\begin{pmatrix} \phantom{-}5.1990556 & -4.2862792 & \phantom{-}0.0872236\\ -1.1722550 & \phantom{-}2.2620970 & -0.0898419\\ \phantom{-}0.1321271 & -0.3146679 & \phantom{-}1.1825408 \end{pmatrix} \end{aligned} \tag{14}

When input and display are Display P3:

MLMSM=(−0.3842671−0.5895472−0.0261857−0.1800798−0.7690428−0.0508774−0.0116227−0.0722697−0.9393530),(MLMSM)−1=(−4.0679056−3.1236934−0.0557878−0.9607645−2.0447289−0.0839644−0.1242496−0.1959623−1.0717127)(15)\begin{aligned} M_{\mathrm{LMS}}M&=\begin{pmatrix} \phantom{-}0.3842671 & \phantom{-}0.5895472 & \phantom{-}0.0261857\\ \phantom{-}0.1800798 & \phantom{-}0.7690428 & \phantom{-}0.0508774\\ -0.0116227 & \phantom{-}0.0722697 & \phantom{-}0.9393530 \end{pmatrix},\\[3mm] \left(M_{\mathrm{LMS}}M\right)^{-1}&=\begin{pmatrix} \phantom{-}4.0679056 & -3.1236934 & \phantom{-}0.0557878\\ -0.9607645 & \phantom{-}2.0447289 & -0.0839644\\ \phantom{-}0.1242496 & -0.1959623 & \phantom{-}1.0717127 \end{pmatrix} \end{aligned} \tag{15}

5. Chromaticity and uniform color spaces

Chromatic Glass moves colors in CIELUV and confines them to the gamut triangle on the u′v′u'v' chromaticity diagram. Two of the three zone methods use distances in CIELUV and Oklab. This section defines those conversions.

5-1. XYZ and u′v′Yu'v'Y

The conversions from XYZ to the CIE 1976 UCS chromaticity coordinates (u′,v′)(u',v') and back are as follows [7].

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

When the denominator is close to 00 (black, etc.), (u′,v′)(u',v') is set to the white point (0.19783, 0.46832)(0.19783,\,0.46832). This chromaticity diagram is a uniform chromaticity diagram, in which differences in chromaticity are roughly proportional to perceived differences, and is better suited than the xyxy diagram for measuring the closeness of colors by distance. A plane through the origin (black) (in LMS or XYZ) is a straight line on u′v′u'v'. The zone boundaries of §6 use this property.

5-2. CIELUV

L∗u∗v∗L^*u^*v^* is given as follows from YrY_r (that is YY divided by the white's YnY_n, here 11), (u′,v′)(u',v') of Eq. (16), and the white's (un′,vn′)(u'_n,v'_n) [7].

L∗={116 Yr1/3−16(Yr>ε)κ Yr(Yr≤ε),ε=21624389,κ=2438927(18)L^*=\begin{cases} 116\,Y_r^{1/3}-16 & (Y_r>\varepsilon)\\ \kappa\,Y_r & (Y_r\le\varepsilon) \end{cases},\qquad \varepsilon=\frac{216}{24389},\quad\kappa=\frac{24389}{27} \tag{18}
u∗=13L∗(u′−un′),v∗=13L∗(v′−vn′)(19)u^*=13L^*(u'-u'_n),\qquad v^*=13L^*(v'-v'_n) \tag{19}

The inverse is: for L∗>8L^*>8, Yr=(L∗+16116)3Y_r=\left(\frac{L^*+16}{116}\right)^3, otherwise Yr=L∗/κY_r=L^*/\kappa, and u′=u∗13L∗+un′u'=\frac{u^*}{13L^*}+u'_n, v′=v∗13L∗+vn′v'=\frac{v^*}{13L^*}+v'_n. For L∗≤0L^*\le 0 (black), u′v′u'v' is the white point and Y=0Y=0. The lower branch of Eq. (18) (Yr≤εY_r\le\varepsilon) is the linear foot for dark colors. Version 2.21 used a pure power function with no foot, so black was L∗=−16L^*=-16 and the inverse divided by zero.

5-3. Oklab

Oklab is Ottosson's uniform color space [14], made from XYZ (D65, YY is 11 for white) with the following matrices.

q′=M1(XYZ),(Lab)=M2 q′3(20)\mathbf{q}'=M_1\begin{pmatrix}X\\Y\\Z\end{pmatrix},\qquad \begin{pmatrix}L\\a\\b\end{pmatrix}=M_2\,\sqrt[3]{\mathbf{q}'} \tag{20}

The cube root is the signed cube root of each component (x3=sgn(x) ∣x∣1/3\sqrt[3]{x}=\mathrm{sgn}(x)\,|x|^{1/3}).

M1=(−0.81893301010.3618667424−0.1288597137−0.03298454360.9293118715−0.0361456387−0.04820030180.2643662691−0.6338517070),M2=(−0.2104542553−0.7936177850−0.0040720468−1.9779984951−2.4285922050−0.4505937099−0.0259040371−0.7827717662−0.8086757660)(21)\begin{aligned} M_1&=\begin{pmatrix} \phantom{-}0.8189330101 & 0.3618667424 & -0.1288597137\\ \phantom{-}0.0329845436 & 0.9293118715 & \phantom{-}0.0361456387\\ \phantom{-}0.0482003018 & 0.2643662691 & \phantom{-}0.6338517070 \end{pmatrix},\\[3mm] M_2&=\begin{pmatrix} \phantom{-}0.2104542553 & \phantom{-}0.7936177850 & -0.0040720468\\ \phantom{-}1.9779984951 & -2.4285922050 & \phantom{-}0.4505937099\\ \phantom{-}0.0259040371 & \phantom{-}0.7827717662 & -0.8086757660 \end{pmatrix} \end{aligned} \tag{21}

If the whole color is multiplied by kk, q′\mathbf{q}' becomes kk times larger and the cube root k1/3k^{1/3} times larger, so L,a,bL,a,b all change by the same factor k1/3k^{1/3}. Therefore a/La/L and b/Lb/L are independent of brightness. The Chroma Gap Method of §6-5 uses this (a/L, b/L)(a/L,\,b/L).

5-4. Gamut triangle

The chromaticities (u′,v′)(u',v') of the primaries of the display color space are obtained by applying Eq. (16) to the XYZ of each primary (the columns of MM in Eqs. (5), (7)) (the blue primary of sRGB is the same as that of Display P3).

Color spaceRGBWhite
sRGB(0.45070, 0.52289)(0.12500, 0.56250)(0.17544, 0.15789)(0.19783, 0.46832)
Display P3(0.49635, 0.52555)(0.09860, 0.57767)(0.17544, 0.15789)(0.19783, 0.46832)

Chromaticities outside this triangle cannot be displayed. §7-6 confines changed colors to this triangle. Version 2.21 hard-coded the sRGB primaries rounded to 4 digits (red (0.4497, 0.5226)(0.4497,\,0.5226), etc.). Version 3.0 computes them from the primaries of the display color space.

6. Distinguish colors: how zones are decided

Distinguish colors gives each pixel color a zone position PP, and changes the colors that fall in the range (zone) chosen with the slider. There are three ways to make PP, chosen in the setting "Zone allocation".

Name in the settingsInternal nameMeaning of the axis
Chart Angle MethodP (standard; same as 2.21)Angle on the chromaticity diagram
Color Appearance Gap MethodADistance in CIELUV between the original color and its projected color (including the lightness difference) ÷ the original L∗L^*
Chroma Gap MethodChDistance in Oklab (a/L, b/L)(a/L,\,b/L) between the original color and its projected color (brightness disappears)

The order in the settings menu is P, A, Ch (the stored value follows this order).

6-1. Confusion lines

Two colors that differ only in the response of the cone corresponding to the type (L for type 1, M for type 2, S for type 3) are hard for that person to distinguish. In LMS space, such two colors lie on a straight line parallel to the axis of that cone. This line is the confusion line. In XYZ space, the direction of a confusion line is the color e\mathbf{e} that stimulates only that cone, that is, the corresponding column of Eq. (12).

eL=(−1.748709, −0.276700, −0.086366)T,eM=(−1.015523, −0.683634, −0.112329)T,eS=(−0.217270, −0.039665, −1.115021)T(22)\begin{aligned} \mathbf{e}_{\mathrm{L}}&=(\phantom{-}1.748709,\ \phantom{-}0.276700,\ \phantom{-}0.086366)^{\mathsf T},\\ \mathbf{e}_{\mathrm{M}}&=(-1.015523,\ \phantom{-}0.683634,\ -0.112329)^{\mathsf T},\\ \mathbf{e}_{\mathrm{S}}&=(\phantom{-}0.217270,\ \phantom{-}0.039665,\ \phantom{-}1.115021)^{\mathsf T} \end{aligned} \tag{22}

The chromaticity of e\mathbf{e} (Eq. (16)) is called the copunctal point. On the u′v′u'v' diagram, confusion lines are straight lines through the copunctal point. The copunctal points are, for type 1 (L) (1.1358, 0.4044)(1.1358,\,0.4044), type 2 (M) (−0.4563, 0.6912)(-0.4563,\,0.6912), type 3 (S) (0.2090, 0.0859)(0.2090,\,0.0859). For types 1 and 2 the copunctal points are far outside the chromaticity diagram and the confusion lines are nearly parallel. The copunctal point of type 3 is below the diagram and its confusion lines fan out (Fig. 1).

6-2. Color perception plane

The whole set of confusion lines is represented by one plane. This is the color perception plane (the single plane of Viénot et al. 1999 [15]). It passes through the origin (black); for types 1 and 2 it passes through the display white, blue and yellow, and for type 3 through white, red and cyan. The plane is determined by the display gamut (sRGB or Display P3) and does not depend on the wavelengths of anchor stimuli. The normal n\mathbf{n} is the cross product of the display white W\mathbf{W} and the blue (types 1, 2) or red (type 3) primary B\mathbf{B}, R\mathbf{R} (columns of MM in Eqs. (5), (7)).

n={W×B(types 1, 2)W×R(type 3)(23)\mathbf{n}=\begin{cases} \mathbf{W}\times\mathbf{B} & (\text{types 1, 2})\\ \mathbf{W}\times\mathbf{R} & (\text{type 3}) \end{cases} \tag{23}

The sRGB values are n=(0.8719106, −0.7068849, −0.1118652)\mathbf{n}=(0.8719106,\,-0.7068849,\,-0.1118652) for types 1 and 2, and n=(−0.2122453, 0.4307443, −0.2102868)\mathbf{n}=(-0.2122453,\,0.4307443,\,-0.2102868) for type 3. For Display P3 they are (0.9575963, −0.7763530, −0.1228586)(0.9575963,\,-0.7763530,\,-0.1228586) for types 1 and 2, and (−0.2493665, 0.5299039, −0.2689407)(-0.2493665,\,0.5299039,\,-0.2689407) for type 3.

Any color c\mathbf{c} (XYZ), moved along the confusion line (in the direction e\mathbf{e}) onto this plane, becomes a color c′\mathbf{c}' that looks the same to that person.

s=n⋅cn⋅e,c′=c−s e(24)s=\frac{\mathbf{n}\cdot\mathbf{c}}{\mathbf{n}\cdot\mathbf{e}},\qquad \mathbf{c}'=\mathbf{c}-s\,\mathbf{e} \tag{24}

ss is how far c\mathbf{c} is from the plane (signed; the red side is ++). Colors on the plane (white, blue, yellow, etc.) have s=0s=0. The difference between c\mathbf{c} and c′\mathbf{c}' is the size of the difference that the person finds hard to distinguish, so using it as an axis lines up the colors the person finds hard to tell apart. In LMS, e\mathbf{e} is a unit vector of an axis, so c′\mathbf{c}' is c\mathbf{c} with ss subtracted from the LMS component corresponding to the type.

Figure 1: Confusion lines (gray) and the trace of the color perception plane (orange line)
Figure 1: Confusion lines (gray) and the trace of the color perception plane (orange line). From the left, type 1, type 2 and type 3. The point where an example color c\mathbf{c} lands when moved along its confusion line onto the plane is c′\mathbf{c}', which looks the same as c\mathbf{c} to that person. The confusion lines are nearly horizontal for type 1, slope downward to the right for type 2, and fan out from one point (the copunctal point) below for type 3.

6-3. Chart Angle Method (P)

A fan center (U0,V0)(U_0,V_0) is placed on the u′v′u'v' chromaticity diagram, and the axis is made from the angle of a color.

P=−atan2⁡(v′−V0,  u′−U0)−θmin⁡θw(25)P=\frac{-\operatorname{atan2}(v'-V_0,\;u'-U_0)-\theta_{\min}}{\theta_{w}} \tag{25}

The fan center is determined from the two points E1\mathbf{E}_1, E2\mathbf{E}_2 where the trace line of the color perception plane (the line through white and the blue primary (types 1, 2) or the red primary (type 3)) meets the gamut triangle. The XYZ of the two points (Y=1Y=1) are scaled so that their sum is proportional to white (s1E1+s2E2=Ws_1\mathbf{E}_1+s_2\mathbf{E}_2=\mathbf{W}), and the center is the chromaticity of s2E2−s1E1s_2\mathbf{E}_2-s_1\mathbf{E}_1 (the harmonic conjugate of white).

(U0,V0)=chromaticity(s2E2−s1E1),s1E1+s2E2=W(26)\begin{aligned} (U_0,V_0)&=\text{chromaticity}\left(s_2\mathbf{E}_2-s_1\mathbf{E}_1\right),\\ &\quad s_1\mathbf{E}_1+s_2\mathbf{E}_2=\mathbf{W} \end{aligned} \tag{26}

θmin⁡\theta_{\min} and θw\theta_w are the angles of the gamut edges, chosen so that for types 1 and 2 the red primary is P=0P=0 and the green primary P=1P=1 (θmin⁡\theta_{\min} is the angle of the red primary, θw\theta_w the difference between the green and red angles), and for type 3 the green primary is P=0P=0 and the blue primary P=1P=1. The position of white, PwP_w, is obtained from the angle of white by Eq. (25). A plane through the origin is a straight line on u′v′u'v', so lines of constant PP are radial straight lines from the fan center. The constants are as follows.

Color spaceType(U₀, V₀)θminθwPosition of white Pw
sRGBTypes 1, 2(0.21460, 0.70083)0.645851.499720.66476
sRGBType 3(0.04225, 0.43475)−0.996022.118420.36985
Display P3Types 1, 2(0.21771, 0.74397)0.664851.527490.64024
Display P3Type 3(−0.00798, 0.42887)−0.949261.925010.39473

The sRGB values agree to within 2.1×10−42.1\times10^{-4} with the values hard-coded in 2.21 (centers (0.214608, 0.700833)(0.214608,\,0.700833) and (0.042256, 0.434763)(0.042256,\,0.434763), θmin⁡=0.64566\theta_{\min}=0.64566 and −0.99599-0.99599, θw=1.49993\theta_w=1.49993 and 2.118362.11836, Pw=0.66478P_w=0.66478 and 0.369880.36988) (2.21 rounded the primaries to 4 digits). Types 1 and 2 use the same fan. The PP of a given color changes with the color space (the slider is a ratio relative to the gamut at that time).

6-4. Color Appearance Gap Method (A)

Using c′\mathbf{c}' of Eq. (24), the CIELUV distance between c\mathbf{c} and c′\mathbf{c}' is divided by the original lightness L∗(c)L^*(\mathbf{c}). The sign follows ss.

A=sign⁡(s)  ∥ Luv(c)−Luv(c′) ∥L∗(c)(27)A=\operatorname{sign}(s)\;\frac{\left\|\,\mathrm{Luv}(\mathbf{c})-\mathrm{Luv}(\mathbf{c}')\,\right\|}{L^*(\mathbf{c})} \tag{27}

Luv(⋅)\mathrm{Luv}(\cdot) is (L∗,u∗,v∗)(L^*,u^*,v^*) by Eqs. (16)–(19) (the white is the display white). The difference in lightness (L∗L^*) between c\mathbf{c} and c′\mathbf{c}' also enters the distance, so AA depends slightly on brightness (differences appear on the blue-violet side).

6-5. Chroma Gap Method (Ch)

The distance of (a/L, b/L)(a/L,\,b/L), that is, Oklab (Eq. (20)) a,ba,b divided by LL, is used.

Ch=sign⁡(s)  ∥ (aL,bL)(c)−(aL,bL)(c′) ∥(28)C_h=\operatorname{sign}(s)\;\left\|\,\left(\tfrac aL,\tfrac bL\right)(\mathbf{c})-\left(\tfrac aL,\tfrac bL\right)(\mathbf{c}')\,\right\| \tag{28}

As in §5-3, a/La/L and b/Lb/L do not depend on brightness, so ChC_h is determined by chromaticity alone (changing the luminance YY from 0.001 to 3 changes the value by only 1.7×10−151.7\times10^{-15}). The confusion line is determined by the cone direction of Eq. (22); Oklab is used only as the yardstick for the distance.

The only difference between A and Ch is the yardstick that measures distance. Both coordinates are converted to the equivalent of PP by Eq. (30) of §6-7 and then compared with the zone of Eq. (29).

6-6. Boundaries on the chromaticity diagram

The three methods are compared by where they draw the zone boundary on the chromaticity diagram.

Figure 2: Type 2, sRGB
Figure 2: Type 2, sRGB. Lines of constant PP are drawn at steps of 0.1. The red line is P=0P=0 (red primary), the green line P=1P=1 (green primary), and the blue dashed lines are ±0.05\pm0.05 around white (§7-4). The orange area is the chromaticity region indicated by slider values 0.6 to 1.0 (P=0∼0.4P=0\sim0.4). The lines of method A move slightly with brightness, so they are drawn at luminance Y=0.3Y=0.3.
  • Chart Angle Method (left): straight lines radiating from the fan center.
  • Color Appearance Gap Method (middle): nearly parallel curves. The zone moves like a vertical band from red to green.
  • Chroma Gap Method (right): curves close to a fan within the gamut. Lines bend sideways near blue.

The same slider values indicate different colors depending on the method. Figure 9 (§11) shows the results with the same values and only the method changed.

6-7. Zones and slider values

The relation between the slider value ss and the axis PP is as in 2.21, s=1−Ps=1-P (left end 00 is the green primary, right end 11 the red primary; for type 3, blue on the left and green on the right). From the start aZa_Z (slider value) and the width ww, the zone is

P∈[Ps, Pe),Ps=(1−aZ)−w2,Pe=(1−aZ)+w2(29)P\in[P_s,\,P_e),\qquad P_s=(1-a_Z)-\frac w2,\quad P_e=(1-a_Z)+\frac w2 \tag{29}

and a color is inside the zone when its PP falls in this range. When "reverse" is on, inside and outside are swapped. w=0w=0 means the zone is off (nothing is changed).

For the Chart Angle Method, PP of Eq. (25) is used as is. The coordinate xx of A and Ch (Eqs. (27), (28)) is converted linearly to PP, using the primaries themselves (at maximum brightness) of the display as reference.

P=a+b x(30)P=a+b\,x \tag{30}

a,ba,b are determined so that the coordinates xlo,xhix_{\mathrm{lo}},x_{\mathrm{hi}} of the red and green primaries (green and blue for type 3) become P=0, 1P=0,\,1: b=1xhi−xlob=\dfrac{1}{x_{\mathrm{hi}}-x_{\mathrm{lo}}}, a=−xlo ba=-x_{\mathrm{lo}}\,b. White lies on the plane, so x=0x=0 and the position of white is Pw=aP_w=a. For types 1 and 2, n/(n⋅e)\mathbf{n}/(\mathbf{n}\cdot\mathbf{e}) of Eq. (24) is the same for sRGB and Display P3, so the equation for the decision does not change when the color space is switched (only a,ba,b change). For type 3 the plane passes through the red primary, so the values differ with the color space. The values are as follows.

TypeColor spaceMethodCoordinates of primaries (R, G, B)a (Pw of white)bSlider value of white 1 − a
Type 1sRGBCh+0.4503, −0.1997, 00.6927−1.53850.307
Type 1sRGBA+3.2355, −1.0345, 00.7577−0.23420.242
Type 2sRGBCh−0.4557, +0.2067, 00.68791.50970.312
Type 2sRGBA−3.2889, +1.0558, 00.75700.23020.243
Type 3sRGBCh0, −0.2753, +0.78440.25980.94360.740
Type 3sRGBA0, −1.3981, +3.90900.26340.18840.737
Type 1Display P3Ch+0.5228, −0.2763, 00.6542−1.25140.346
Type 1Display P3A+3.8289, −1.3924, 00.7333−0.19150.267
Type 2Display P3Ch−0.5133, +0.2824, 00.64511.25680.355
Type 2Display P3A−3.8833, +1.4179, 00.73250.18860.268
Type 3Display P3Ch0, −0.3309, +0.79290.29440.88990.706
Type 3Display P3A0, −1.6395, +3.94500.29360.17910.706

The position of white for the Chart Angle Method is PwP_w of Eq. (25) (table of §6-3). Within the gamut, PP stays within about 00–11 (for Ch the ends coincide with the primaries, so exactly 00–11; for A with type 2, −0.013-0.013 to 1.0011.001). Values outside the range are not clipped but compared as they are with Eq. (29).

Figure 3: Where the same colors lie on the slider (type 2, sRGB)
Figure 3: Where the same colors lie on the slider (type 2, sRGB). The red and green at the ends agree for the three methods, but intermediate colors shift with the method. For example, orange is at 0.77 for the Chart Angle Method, 0.68 for the Chroma Gap Method and 0.60 for the Color Appearance Gap Method. Yellow and blue lie at the same position as white in every method (because they are colors on the color perception plane).
  • The positions of the red, green and blue primaries agree for the three methods, so the two ends of the slider have the same meaning.
  • A stored value (zone start and width) indicates a different range of colors with the same value when the method is switched.
  • The correspondence of A is the value at the primaries (maximum brightness), so it shifts for dark colors (because A depends on brightness). Ch does not shift.

Uniformity of the coordinates. For type 1 and sRGB, when colors are moved along a confusion line, the Oklab distance per unit of coordinate, as a ratio with white as 1 (7 colors: white, gray, skin, yellow, blue-green, blue, dark red), had a max/min of 4.2 for P, 2.7 for Ch and 4.8 for A. Ch narrows the width of blue (the value for blue is 2.35 for P, 0.53 for Ch, 1.18 for A). Only 7 colors and only type 1 were measured.

7. How colors are changed (common to Distinguish and Find)

A color that enters the zone (or the circle around the target color) is moved in CIELUV, confined to the gamut triangle on the chromaticity diagram, and clipped back to the display gamut.

7-1. Direction of the confusion line in CIELUV, nL\mathbf{n}_{\mathrm{L}}

The direction of change is taken different from the direction of the difference the person finds hard to distinguish. First the direction of the color's confusion line within CIELUV is found. The difference between the CIELUV of a color q\mathbf{q} (LMS) and that of the color q0\mathbf{q}_0 with the component of the cone corresponding to the type set to 00 (Eqs. (16)–(19); LMS is returned to XYZ by Eq. (12)) is normalized.

nL=σ(Luv(q)−Luv(q0))∥Luv(q)−Luv(q0)∥,σ={+1(types 1, 3)−1(type 2)(31)\begin{aligned} \mathbf{n}_{\mathrm{L}}&=\frac{\sigma\left(\mathrm{Luv}(\mathbf{q})-\mathrm{Luv}(\mathbf{q}_0)\right)}{\left\|\mathrm{Luv}(\mathbf{q})-\mathrm{Luv}(\mathbf{q}_0)\right\|},\\[3mm] \sigma&=\begin{cases}+1&(\text{types 1, 3})\\-1&(\text{type 2})\end{cases} \end{aligned} \tag{31}

The sign σ\sigma is the same as in 2.21. For white (q=(1,1,1)\mathbf{q}=(1,1,1)) the values are (0.0234, 0.9974, −0.0680)(0.0234,\,0.9974,\,-0.0680) for type 1, (−0.0754, 0.9439, −0.3215)(-0.0754,\,0.9439,\,-0.3215) for type 2 and (0.0115, 0.0293, −0.9995)(0.0115,\,0.0293,\,-0.9995) for type 3 (with the 2.21 cones they were (0.0293, 0.9992, −0.0262)(0.0293,\,0.9992,\,-0.0262), (−0.0643, 0.9586, −0.2773)(-0.0643,\,0.9586,\,-0.2773) and (0, 0.1154, −0.9933)(0,\,0.1154,\,-0.9933)). When the difference is close to 00 (<10−12<10^{-12}), (1,0,0)(1,0,0) is used.

7-2. Rotation

The rotation that maps the L∗L^* axis (1,0,0)(1,0,0) to nL=(n1,n2,n3)\mathbf{n}_{\mathrm{L}}=(n_1,n_2,n_3) is given by the following matrix, with ρ=n22+n32\rho=\sqrt{n_2^2+n_3^2}, c=n3/ρc=n_3/\rho, t=n2/ρt=n_2/\rho, ς=1−n12\varsigma=\sqrt{1-n_1^2} (multiplied from the right on a row vector: v↦vR\mathbf{v}\mapsto\mathbf{v}R).

R=(n1ςtςc0c−t−ςn1tn1c)(32)R=\begin{pmatrix} n_1 & \varsigma t & \varsigma c\\ 0 & c & -t\\ -\varsigma & n_1 t & n_1 c \end{pmatrix} \tag{32}

When ρ<10−12\rho<10^{-12}, c=1c=1 and t=0t=0 (2.21 divided by 0 and the value was undefined).

7-3. Normal method: circle in the plane perpendicular to the confusion line

The change vector (CIELUV) is given by the following.

Δ=f⋅100⋅(0,  cos⁡θ,  sin⁡θ) R,θ=2π(1−age)+(1.5−g)π(33)\begin{aligned} \Delta&=f\cdot100\cdot(0,\;\cos\theta,\;\sin\theta)\,R,\\ \theta&=2\pi(1-\mathrm{age})+\left(1.5-g\right)\pi \end{aligned} \tag{33}

The changed color is (L∗,u∗,v∗)+Δ(L^*,u^*,v^*)+\Delta. (0,cos⁡θ,sin⁡θ)(0,\cos\theta,\sin\theta) is a circle perpendicular to the L∗L^* axis, and RR turns it into the plane perpendicular to nL\mathbf{n}_{\mathrm{L}}, so Δ\Delta is orthogonal to nL\mathbf{n}_{\mathrm{L}}. The component along the confusion line does not change; only the difference that the person can distinguish increases.

  • Radius =f⋅100=f\cdot100: the change magnitude ff (distance from the center of the 2D slider, 00 to 0.50.5). The constant 100100 is as in 2.21.
  • Angle θ\theta: the color rotation age\mathrm{age} (angle of the 2D slider; 00 at the top, one turn clockwise).
  • gg: green-side inversion (§7-4), 00 or 11.
Figure 4: Change in CIELUV
Figure 4: Change in CIELUV. For each of three colors (magenta-red, green, blue), the large circle is the original color. The red lines are confusion lines of type 1 and the green lines those of type 2, passing through each color. The ring of circles is the circle in the plane perpendicular to each confusion line (radius = change magnitude 0.35 × 100), drawn with a red rim for type 1 and a green rim for type 2. On the circle, the changed colors for 36 equal steps of color rotation are placed, painted in the colors the app displays. Different types have different confusion-line directions, so the planes of the circles also differ. The small circles away from them are the vertices of the sRGB cube (white, black, red, green, blue, cyan, magenta, yellow).

The 2D (circular) slider determines the change magnitude ff by the distance from the center, and the color rotation age\mathrm{age} by the angle. Even at the same position, the way a color changes depends on the original color.

Figure 5: Result of changing the color at the center of the disc with the setting of each point of the disc (distance f, angle \mathrm{age}) (type 2)
Figure 5: Result of changing the color at the center of the disc with the setting of each point of the disc (distance ff, angle age\mathrm{age}) (type 2). The upper half of the disc becomes brighter and the lower half darker. The side of age\mathrm{age} 0.25 (right) moves toward yellow and orange, and the side of 0.75 (left) toward purple-red and blue-green.

7-4. The π shift on the green side, and the achromatic band

Green-side inversion. When "red-green inversion" is on, a color on the green side of the position of white PwP_w (P>PwP>P_w) gets g=1g=1, and the angle of Eq. (33) is shifted by π\pi. Colors on the red side and on the green side move in opposite directions, so the red side and green side can still be told apart after the change. In the boost method, the ring is used shifted by two nodes (§7-5). PwP_w is the position of white for each method (§6-3, §6-7).

Achromatic band. Colors close to white (gray, a white background) have no hue, so we do not want to change them. When "keep achromatic colors" is on, a color whose PP is within Pw±0.05P_w\pm0.05 around the position of white has its change set to 00 even if it is in the zone (half of the 0.10.1 band width of 2.21).

feff={0(∣P−Pw∣≤0.05 and “keep” is on)fotherwise(34)f_{\mathrm{eff}}=\begin{cases}0 & (|P-P_w|\le0.05\ \text{and ``keep'' is on})\\ f & \text{otherwise}\end{cases} \tag{34}

The apparent width of ±0.05\pm0.05 differs with the method (for A and Ch it is wider on the blue and red sides than for P).

Figure 6: The axis of the zone position P (Chart Angle Method, type 2)
Figure 6: The axis of the zone position PP (Chart Angle Method, type 2). The orange band is the zone, the blue band the achromatic band, and the green arrow the range of the π shift on the green side. Yellow is a color on the color perception plane, so it lies at the same position as white.

7-5. Boost method

When boost is on (Distinguish only), instead of the circle of Eq. (33), colors are moved toward a target color on a ring. The ring joins four nodes in order: white → 575 nm yellow → black → 475 nm blue (for type 3, 660 nm red and 485 nm blue-green). The nodes are given in u′v′Yu'v'Y (Eq. (16)), and the XYZ of the anchor stimuli use the values (xˉ10,yˉ10,zˉ10)(\bar x_{10},\bar y_{10},\bar z_{10}) of the CIE 1964 10° color matching functions (JIS Z 8701, Appendix Table 2 [9]).

Anchor stimulus(x̄₁₀, ȳ₁₀, z̄₁₀)Node (u′, v′, Y)
575 nm(0.9512, 0.9152, 0.0000)(0.25920, 0.56112, 0.9152)
475 nm(0.1323, 0.2199, 1.0302)(0.08115, 0.30348, 0.2199)
660 nm(0.1526, 0.0603, 0.0000)(0.57743, 0.51339, 0.0603)
485 nm(0.0411, 0.2977, 0.5701)(0.02644, 0.43097, 0.2977)
White—(0.19783, 0.46832, 1)
Black—(0.19783, 0.46832, 0)

The CIELUV values of the nodes (Eqs. (18), (19)) are, for types 1 and 2: white (100, 0, 0)(100,\,0,\,0), 575 nm (96.62, 77.08, 116.57)(96.62,\,77.08,\,116.57), black (0, 0, 0)(0,\,0,\,0), 475 nm (54.02, −81.94, −115.75)(54.02,\,-81.94,\,-115.75); for type 3: white (100, 0, 0)(100,\,0,\,0), 660 nm (29.49, 145.52, 17.28)(29.49,\,145.52,\,17.28), black (0, 0, 0)(0,\,0,\,0), 485 nm (61.46, −136.92, −29.84)(61.46,\,-136.92,\,-29.84). Version 2.21 used L∗=−16L^*=-16 for the black node.

Let the nodes be r0,r1,r2,r3\mathbf{r}_0,\mathbf{r}_1,\mathbf{r}_2,\mathbf{r}_3 (CIELUV), let the integer part kk (0≤k≤30\le k\le3) of 4 age4\,\mathrm{age} select the node, and the fractional part ϕ\phi the position between nodes. The target color t\mathbf{t} and the changed color are

t=(1−ϕ) r(k+2g) mod 4+ϕ r(k+1+2g) mod 4,Luvnew=Luv+(t−Luv)⋅2feff(35)\begin{aligned} \mathbf{t}&=(1-\phi)\,\mathbf{r}_{(k+2g)\bmod 4}+\phi\,\mathbf{r}_{(k+1+2g)\bmod 4},\\ \mathrm{Luv}_{\mathrm{new}}&=\mathrm{Luv}+\left(\mathbf{t}-\mathrm{Luv}\right)\cdot2f_{\mathrm{eff}} \end{aligned} \tag{35}

(Luv\mathrm{Luv} is the CIELUV of the original color). The target is reached at change magnitude f=0.5f=0.5. The upper limit of the 2D slider is 0.50.5, so the target is never overshot (above 0.50.5 it would extrapolate, but the screen does not produce such values). On the green side (g=1g=1) the ring is used shifted by two nodes.

Figure 7: Left: the four nodes of the ring
Figure 7: Left: the four nodes of the ring. Right: the target color as age\mathrm{age} goes from 00 to 11 (top: red side, bottom: green side). The green side is the red side shifted by half a turn.

7-6. Confining to the gamut

The CIELUV of the changed color is returned to u′v′Yu'v'Y (inverse of Eq. (19)). When its chromaticity u1=(u′,v′)\mathbf{u}_1=(u',v') leaves the gamut triangle of the display (§5-4), the segment from the chromaticity u0\mathbf{u}_0 of the original color toward u1\mathbf{u}_1 is stopped at the point where it reaches the boundary of the triangle. For edge ii of the triangle (vertices ai\mathbf{a}_i, ai+1\mathbf{a}_{i+1}), the signed distance with the inside positive is

di(p)=ϖ[(ai+1,u−ai,u)(pv−ai,v)−(ai+1,v−ai,v)(pu−ai,u)](36)d_i(\mathbf{p})=\varpi\left[(a_{i+1,u}-a_{i,u})(p_v-a_{i,v})-(a_{i+1,v}-a_{i,v})(p_u-a_{i,u})\right] \tag{36}

(ϖ=±1\varpi=\pm1 is the orientation of the triangle). With f0=max⁡(di(u0),0)f_0=\max(d_i(\mathbf{u}_0),0) and f1=di(u1)f_1=d_i(\mathbf{u}_1), among the edges with f1<0f_1<0 take the one with the smallest ti=f0/(f0−f1)t_i=f_0/(f_0-f_1) (if no edge is crossed, t=1t=1), and let

u=u0+(u1−u0) t,Y=clip[0,1](Y1)(37)\begin{aligned} \mathbf{u}&=\mathbf{u}_0+(\mathbf{u}_1-\mathbf{u}_0)\,t,\\ Y&=\mathrm{clip}_{[0,1]}(Y_1) \end{aligned} \tag{37}

be the chromaticity and brightness of the changed color. In 2.21, when the original color was on an edge (a saturated color), the intersection test (product of signs) was decided by rounding and the answer differed between single and double precision. This equation computes tt after clamping the distance of the original color to 00 or more, so it gives the same answer regardless of precision (the same as 2.21 for general colors).

Then the display linear RGB (Eqs. (6), (8)) is obtained from the XYZ of the changed color (Eq. (17)), clipped component-wise to 00–11, and encoded (Eq. (2)).

(R′G′B′)=clip[0,1] ⁣(Mout−1 cnew),V′=Eq. (2) applied to R′,G′,B′(38)\begin{aligned} \begin{pmatrix}R'\\G'\\B'\end{pmatrix}&=\mathrm{clip}_{[0,1]}\!\left(M_{\mathrm{out}}^{-1}\,\mathbf{c}_{\mathrm{new}}\right),\\ V'&=\text{Eq. (2) applied to }R',G',B' \end{aligned} \tag{38}

A hue-preserving confinement (lowering brightness while keeping chromaticity) is not used (it is the same component-wise clipping as the strength blending of the Chromatic Vision Simulator).

8. Find colors

Find colors changes only colors close to the target color. It is used when you want to find a specific color (for example, a ripe red fruit) among colors that are hard to tell apart. It does not use the zone axis PP but decides by the distance on the u′v′u'v' chromaticity diagram.

8-1. Target color

The target color is decided in one of two ways.

  • Tap the image to place the cursor. The color under the cursor (the color averaged smoothly over the surrounding pixels) becomes the target color.
  • Choose from the band of 11 basic colors (colors of the Munsell symbols N, R, YR, Y, GY, G, BG, B, PB, P, RP). The cursor moves to the center of that color chip and that color becomes the target color.

The target color (encoded value cs\mathbf{c}_s of the input) is converted to the chromaticity s=(us′,vs′)\mathbf{s}=(u'_s,v'_s) by Eqs. (1), (5) or (7), and (16). Brightness is not considered, so bright and dark areas of the same hue are found alike.

8-2. Range and how colors are changed

A pixel is changed when its chromaticity (u′,v′)(u',v') is close to the chromaticity of the target color.

(u′−us′)2+(v′−vs′)2  <  wS⋅0.1(39)\sqrt{(u'-u'_s)^2+(v'-v'_s)^2}\;<\;w_S\cdot0.1 \tag{39}

wSw_S is the value of the range slider (the radius setting; symmetric about 0.50.5, only the distance changes), from 00 to 11. At width 11, colors up to a u′v′u'v' distance of 0.10.1 (the same value as 2.21) are included. Pixels that satisfy Eq. (39) are changed by the normal method of §7-3 (Eq. (33)) with the change magnitude ff (distance on the 2D slider) and the color rotation age\mathrm{age} (the same angle). Pixels that do not are left unchanged.

  • In Find, the green-side π shift (§7-4), the achromatic band (§7-4) and boost (§7-5) are not used (as in 2.21; boost is for Distinguish only).
  • The range is a circle on the chromaticity diagram, so if the target color is close to white, achromatic and pale colors close to white enter the circle.
Figure 8: Circles on the u'v' chromaticity diagram around the target color (the color of a red tomato)
Figure 8: Circles on the u′v′u'v' chromaticity diagram around the target color (the color of a red tomato). Widths 0.2, 0.5, 1.0 become circles of distance 0.02, 0.05, 0.10. Colors inside a circle are changed. The orange is just outside the circle of width 0.5.

9. Simulation and display of color names

Simulation simulates how an image looks to a person of type 1, 2 or 3 by the same method as Chromatic Vision Simulator 4.0. The equations and constants are the same; §5 of the theory of Chromatic Vision Simulator 4.0 gives the coefficients of the half-planes (Eqs. (17)–(20)), continuity at the boundary, blending by strength (interpolation in Oklab) and clipping to the gamut. The main points are:

  • The color of a pixel is mapped into LMS space, and the component of the cone corresponding to the type is projected onto two half-planes (the folded plane of Brettel et al. [1]) (anchor stimuli of 475 nm and 575 nm for types 1 and 2, and 485 nm and 660 nm for type 3).
  • With strength kk (00 to 11), the result is blended with the original color by interpolation in Oklab, ok=(1−k) o(q)+k o(qs)\mathbf{o}_k=(1-k)\,\mathbf{o}(\mathbf{q})+k\,\mathbf{o}(\mathbf{q}_s) (both ends are first clipped to the display gamut). This only shows the intermediate image between the most severe form of dichromacy and the original image; it does not simulate the color appearance of anomalous trichromacy (mild color vision deficiency).
  • The result is confined to the display gamut and encoded.

In Chromatic Glass, the simulation is applied after the change. When the "eye" button is on, the simulation is overlaid on the colors changed by Distinguish or Find, so you can check how the changed colors look to that person. A simulation without any color change is done on the screen of the Simulation function.

The display of color names (the name of the color under the cursor) also works as in Chromatic Vision Simulator 4.0. The colors around the cursor are averaged, and the Munsell value, the systematic color name and the common color name are looked up in a dictionary. See §7 of the theory of Chromatic Vision Simulator 4.0 for details.

10. Overall conversion

The conversion from encoded input cin\mathbf{c}_{\mathrm{in}} to encoded output cout\mathbf{c}_{\mathrm{out}} can be written as the composition of §2 to §9. Only the pixels selected by the zone or target-color decision receive the change in CIELUV.

cout=E ⁣(clip[0,1] ⁣(Mout−1 T ⁣(Min D(cin))))(40)\mathbf{c}_{\mathrm{out}}=\mathcal{E}\!\left(\mathrm{clip}_{[0,1]}\!\left(M_{\mathrm{out}}^{-1}\,\mathcal{T}\!\left(M_{\mathrm{in}}\,\mathcal{D}(\mathbf{c}_{\mathrm{in}})\right)\right)\right) \tag{40}

Here D\mathcal{D} is decoding (Eq. (1)), E\mathcal{E} encoding (Eq. (2)), and MinM_{\mathrm{in}}, MoutM_{\mathrm{out}} the RGB-to-XYZ matrices of the input and the display (Eqs. (5), (7)). T\mathcal{T} is the change on XYZ, consisting of the decision (§6 or §8), the change in CIELUV (§7-3 or §7-5), confinement to the gamut triangle (§7-6) and the simulation (§9, when on). For pixels that are not changed, T\mathcal{T} is the identity, and the original color is returned.

11. Sample images

The subject is a cherry tomato (the original image on the site). All are for type 2, made with the same equations as in the figures (a copy of the app's reference implementation).

Figure 9: **Difference of the three methods.** Zone 0.6 to 1.0 (start 0.8, width 0.4), change magnitude 0.3, color rotation 0; **the same values, with only the method changed**
Figure 9: Difference of the three methods. Zone 0.6 to 1.0 (start 0.8, width 0.4), change magnitude 0.3, color rotation 0; the same values, with only the method changed. The top row shows the pixels that fell in the zone (kept bright). Even with the same values, the range of fruit that enters the zone differs by method. The bottom row shows the result of changing colors.
Figure 10: **Color rotation.** Top: normal method; bottom: boost method
Figure 10: Color rotation. Top: normal method; bottom: boost method. As the color rotation is moved through 0, 0.25, 0.5 and 0.75, the red fruit goes around in the normal method through pale pink → orange → dark reddish brown → purple-red. In the boost method, with the same rotation, colors approach colors on the ring white → yellow → black → blue.
Figure 11: **Achromatic band and green-side inversion.** The zone covers the whole range (0 to 1) and the change magnitude is 0.4
Figure 11: Achromatic band and green-side inversion. The zone covers the whole range (0 to 1) and the change magnitude is 0.4. "No band" also tints the white background. With "keep achromatic colors" on, the white background stays as it was and only the colored fruit changes. With "shift the green side by π" alone, a background slightly on the green side of white darkens. With both "keep" and "shift by π" on, the background stays as it is and only the green fruit moves in the direction opposite to the red fruit (the darker direction).
Figure 12: **Find colors.** The target color is the color at one point of a red tomato, and the range (width) was changed to 0.2, 0.5 and 1.0 (change magnitude 0.3, color rotation 0)
Figure 12: Find colors. The target color is the color at one point of a red tomato, and the range (width) was changed to 0.2, 0.5 and 1.0 (change magnitude 0.3, color rotation 0). The top row shows the pixels inside the circle. As the width grows, the range extends to the darker parts of the red fruit and to the orange fruit. The bottom row shows the result of changing colors. Colors outside the circle do not change.

References

[1] H. Brettel, F. Viénot, and J. D. Mollon, "Computerized simulation of color appearance for dichromats", Journal of the Optical Society of America A, vol. 14, no. 10, pp. 2647–2655, 1997. doi:10.1364/JOSAA.14.002647

[2] K. Asada, "Chromatic Vision Simulator", README of the Android source code (appendix: mathematical expressions for color vision simulation), GitHub repository asada0/ChromaticVisionSimulator, 2018, MIT License.

[3] 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.

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

[5] Apple Inc., "Display P3", Three Component Color Encoding Registry (ICC Registry), International Color Consortium, version 1.0, 2022. https://registry.color.org/rgb-registry/displayp3

[6] 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

[7] CIE 15:2004, Colorimetry, 3rd ed., Commission Internationale de l'Éclairage, 2004 (including u′v′u'v' and CIELUV).

[8] G. Wyszecki and W. S. Stiles, Color Science: Concepts and Methods, Quantitative Data and Formulae, 2nd ed., John Wiley & Sons, 1982.

[9] JIS Z 8701:1999, Colour specification — The CIE 1931 standard colorimetric system and the CIE 1964 supplementary standard colorimetric system, Japanese Standards Association, 1999. Appendix Table 2 (spectral chromaticity coordinates of the X10Y10Z10 system; the source of the 10° anchor stimuli).

[10] R. W. G. Hunt and M. R. Pointer, "A colour-appearance transform for the CIE 1931 standard colorimetric observer", Color Research & Application, vol. 10, no. 3, pp. 165–179, 1985. doi:10.1002/col.5080100306

[11] M. D. Fairchild, Color Appearance Models, 3rd ed., John Wiley & Sons, 2013. doi:10.1002/9781118653128

[12] C. Poynton, Digital Video and HD: Algorithms and Interfaces, 2nd ed., Morgan Kaufmann, 2012.

[13] Colour & Vision Research Laboratory, UCL Institute of Ophthalmology, "CIE 1931 2-deg XYZ color matching functions (ciexyz31_1.csv)" and "CIE 1964 10-deg XYZ color matching functions (ciexyz64_1.csv)", http://cvrl.ioo.ucl.ac.uk/cmfs.htm

[14] B. Ottosson, "A perceptual color space for image processing", blog post, 23 December 2020, https://bottosson.github.io/posts/oklab/

[15] F. Viénot, H. Brettel, and J. D. Mollon, "Digital video colourmaps for checking the legibility of displays by dichromats", Color Research & Application, vol. 24, no. 4, pp. 243–252, 1999.