<<

arXiv:1802.06067v1 [eess.IV] 16 Feb 2018 admdl u n igv noeve of overview an give Li and Luo model. ward [3] model appearance CIECAM02 The a o eevdmc teto vrteyears. the over attention much received not has model. first forward the the in of steps only CIECAM02 original differs the algorithm from updated The the circumvent [1]. best breakdown to how on suggestion theirown gave [1] Luo and Li recently, Most therein. references see [2]; improvements suggested for-the the of steps first the most modifying behavior, by them this of for fixes research suggests of number articles fair A for values. down input certain breaks CIECAM02 that quicklydiscovered was it However, popular so model. ever color the CIELAB to successor a as generally of was thought and attention much attracted has Introduction 1. cases. edge all correctly for works and efficient, more shorter, but al- CIECAM02/CAM16, is to model equivalent gebraically color resulting remedies The and suggested. out are pointed al- are Several flaws gorithmic model. appearance the successor, color its CAM16 and model appearance color ∗ h ae ore fti ril r on are article this of sources LaTeX The loihi mrvmnsfrteCIECAM02 the for improvements Algorithmic tapasta htters ftealgorithm the of rest the that that appears It CIECAM02 the with concerned is note This https://github.com/nschloe/note-on-cam16 n A1 oo pernemodels appearance color CAM16 and eray1,2018 19, February ioSchlömer Nico 1 h rgnlSe ftefradmdlreads model forward the of 3 Step original The and CAM16 of flaws the describes section This pne(eutn ndnmcrnecompres- range sion). dynamic in (resulting sponse 3. Step model forward 3, Step 2.1. appear- there. apply steps color trivially listed CIECAM02 and model All the ance in see. appear to also harder triv- are are others them of ial, Some them. for fixes suggests fixes and Flaws 2. [4]. colorio package software open-source the in works and cases. – edge all implement to easier and faster hence – simpler is but CIECAM02/CAM16, the to equivalent entirely model is A) resulting (Section The description im- 2). suggests (Section and doc- provements flaws present those The describes lead again. ument cases once edge downs in break compli- to and more necessary, are than steps version cated the updated of its some and CAM16, CIECAM02 both In l nig nti ril r mlmne in implemented are article this in findings All R a aclt h otdpaincn re- cone postadaptation the Calculate = 400  F 100 L R  c F  100 L 0 R . 42 c  + 0 . 42 27 . 13 + ∗ 0 . 1 with fixes without 2.2. Linear combinations, forward model J 0.0 3.258e-22 C 0.0 4.071e-24 h 0.0 0.0 In the forward model, four linear combinations Q 0.0 2.233e-10 of Ra′ , Ga′ , and Ba′ have to be formed. They can M 0.0 2.943e-24 conveniently be expressed as the matrix-vector s 0.0 1.148e-05 multiplication

Table 1: CAM16 values upon input X = Y = Z = 1 0 with and without the fixes in p2′ 2 1 20 R this article. The exact solutions are a 1 12 1 a′ ≔ 11 11 zeros for every entry. 1 −1 2 Ga′ © b ª © 9 9 9 ª ­ ® ­ − ® Ba′ ­ ® ­ 21 ® © ª ­ u ® ­1 1 ® ­ ® ­ ® ­ 20 ® If Rc is negative, then « ¬ « ¬ « ¬ 0.42 FL Rc which on many platforms can be computed − 100 R = 400   + 0.1 significantly faster than four individual dot- a 0.42 − FL Rc + products. The last variable u is used in the − 100 27.13   computation of t in step 9. and similarly for the computations of Ga and Ba.

If the sign operator is used here as it is used later in step 5 of the inverse model, the above 2.3. Step 9, forward model description can be shortened. Furthermore, the term 0.1 is added here, but Step 9. Calculate the correlates of [. . . ] satu- in all of the following steps in which Ra is used ration (s). – except the computation of t in Step 9 –, it can- cels out algebraically. Unfortunately, said can- s ≔ 100 M Q. cellation is not always exact when computed in / floating point arithmetic. Luckily, the adverse p effect of such rounding errors is rather limited here. The results will only be distorted for very This expression is not well-defined if Q = 0, = = = small input values, e.g., X Y Z 0; see Ta- a value occurring if the input values are X = ble 1. For the sake of consistency, it is advisable Y = Z = 0. When making use of the definition to include the term 0.1 only in the computation of M and Q, one gets to an expression for s that of t in Step 9: is well-defined in all cases:

0.42 FL Rc 100| | R = 400 sign R   . 0.9 n 0.73 a′ c 0.42 α ≔ t 1.64 0.29 , (1) ( ) FL Rc | | + 27.13 ( − ) 100 cα   s ≔ 50 . r Aw + 4

2 2.4. Steps 2 and 3, inverse model It turns out that both of these problems can be avoided quite elegantly. Consider, in the case Step 2. Calculate t, et , p1, p2, and p3. sin h cos h : | ( )| ≥| ( )| 1 . 0 9 ≔ 50000 C p1′ Nc Ncb et, t = , 13 J n 0.73 + 460 © 1.64 0.29 ª p2 2 p3 1403 ­ 100 ( − ) ® b = ( ) q p′ 220 cos h 27 6300 ­1 ® 1 + 2 + p ( ) + p = + + t sin h 3 1403 sin h 1403 3 1403 et « cos h′π 180° 2 3¬.8 , ( ) ( ) ( ) − 4 [ ( / ) ] t sin h p 2 + p 460 = 2 3 1403 = 50000 1 ( ) ( ) p1 Nc Ncbet , p + t 2 + p 220 cos h + t sin h 6588 13 t 1′ ( 3) 1403 ( ) ( ) 1403 A 23t sin h p2 p2 = + 0.305, = ( ) , N + + bb 23p1′ 11t cos h 108t sin h 21 ( ) ( ) p = . 3 20 and

= 23t cos h p2 Step 3. Calculate a and b. If t 0, then a = ( ) . = = 23p + 11t cos h + 108t sin h a b 0 and go to Step 4. In the next com- 1′ ( ) ( ) putations be sure transform h from degrees to Conveniently, the exact same expressions are radians before calculating sin h and cos h : If ( ) ( ) retrieved in the case cos h > sin h . These sin h cos h then | ( )| | ( )| | ( )| ≥ | ( )| expressions are always well-defined since p p = 1 , 4 + + sin h 23p1′ 11t cos h 108t sin h ( ) 460 ( ) ( ) p2 2 + p3 23p′ p2 b = ( ) 1403 , = 1 > 0. + + 220 cos h 27 + 6300 R + G + 21 B + 0.305 p4 2 p3 1403 sin(h) 1403 p3 1403 a′ a′ 20 a′ ( ) ( ) − cos h a = b ( ). In the algorithm, the value of t can be re- sin h ( ) trieved via α (1) from the input variables. In- deed, if the saturation correlate s is given, one If cos h > sin h then | ( )| | ( )| has s 2 A + 4 p1 α ≔ w ; p5 = , cos h  50  c ( ) . p 2 + p 460 if M is given, one can compute C ≔ M F0 25 = 2 3 1403 / L a ( ) , and then + + 220 27 6300 sin h p5 2 p3 1403 1403 p3 1403 cos(h) ( ) −  −  ( ) = sin h 0 if J 0, b = a ( ) . ≔ cos h α  C ( )  otherwise.  J 100 / Some of the complications in this step stem  p  from the fact that the variable t might be 0 in the It is mildly unfortunate that one has to intro- denominator of p1. Likewise, the distinction of duce a case distinction for J = 0 here, but this cases in sin h and cos h is necessary to avoid is an operation that can still be performed at ( ) ( ) division by 0 in a and b. reasonable efficiency.

3 2 without fixes • Luminance of test adapting field (cd m− ): 0.6 with fixes LA. LA is computed using

EW Yb LWYb 0.4 LA = = , π YW YW

0.2 Time in seconds where EW = πLW is the illuminance of reference in lx; LW is the luminance 2 0 of reference white in cd m− ; Yb is the lu- 0 0.2 0.4 0.6 0.8 1 minance factor of the background; and Yw Number of input samples 106 is the luminance factor of the reference · white. Figure 1: Performance comparison of the con- version from CAM16 to XYZ (with J, C, and h), implemented in colorio [4]. • Surround parameters are given in Table 2: The suggested improvements in the To determine the surround conditions see inverse model lead to a speed-up of the note at the end of Part 1 of Appendix about 5%. A of [1].

A. Full model • Nc and F are modelled as a function of c, and their values can be linearly interpo- For the convenience of the reader, both forward lated, using the data from 2. and inverse steps of the improved CAM16 al- gorithm are given here. The wording is taken from [1] where applicable. The steps that dif- Let M16 be given by fer from the original model are marked with an asterisk (*). R 0.401288 0.650173 0.051461 As an abbreviation, the bold letter is used − M ≔ 0.250268 1.204414 0.045854 . whenever the equation applies to R, G, and B 16 − alike. © 0.002079 0.048952 0.953127 ª ­− ® « ¬ Illuminants, viewing surrounds set up and background parameters (See the note at the A.1. Forward model end of Part 2 of Appendix B of [1] for determin- ing all parameters.) Step 0*. Calculate all values/parameters which are independent of the input sample. • Adopted white in test illuminant: Xw, Yw, Zw Rw Xw • Background in test conditions: Yb Gw = M16 Yw , • Reference white in reference illuminant: ©Bw ª ©Zwª X = Y = Z = 100, fixed in the ­ ® ­ ® wr wr wr D = F 1 1 exp La 42 . « ¬ 3.«6 ¬ − 92− model h −  i

4 F c Nc Step 2. Complete the color adaptation of the illuminant in the corresponding cone response Average 1.0 0.69 1.0 space (considering various luminance levels Dim 0.9 0.59 0.9 and surround conditions included in D, and Dark 0.8 0.525 0.8 hence in DR, DG, and DB).

Table 2: Surround parameters. Rc = DR R · Red Step 3*. Calculate the modified postadapta- tion cone response (resulting in dynamic range i 1 2 3 4 5 compression). hi 20.14 90.00 164.25 237.53 380.14 e 0.8 0.7 1.0 1.2 0.8 0.42 i FL Rc | | Hi 0.0 100.0 200.0 300.0 400.0 100 R = 400 sign R   . a′ c 0.42 ( ) FL Rc + Table 3: Unique data for calculation of hue 100| | 27.13   quadrature. Step 4*. Calculate Redness–Greenness (a), Yellowness–Blueness (b) components, hue an- If D is greater than one or less than zero, set it gle (h), and auxiliary variables (p′ , u). to one or zero, respectively. 2 1 YW p2′ 2 1 20 DR = D 1 + D, R R − a 1 12 1 a′ W ≔ − 11 11 G , 1 1 1 2 a′ = © b ª © 9 9 9 ª k , ­ ® ­ − ® ©Ba′ ª 5LA + 1 ­ ® ­ 21 ® ­ u ® ­1 1 20 ® ­ ® 4 4 2 1 3 ­ ® ­ ® FL = k LA + 0.1 1 k 5LA / , ≔ « ¬ ( − ) ( ) h arctan b a . Y « ¬ « ( / ) ¬ n = b , YW (Make sure that h is between 0° and 360°.) z = 1.58 + √n, Step 5. Calculate eccentricity [et , hue quadra- 0.725 N = , ture composition (H) and hue composition bb 0.2 n (Hc)]. Ncb = Nbb, Using the following unique hue data in ta- = + Rwc = DR Rw, ble 3, set h′ h 360° if h < h1, otherwise 0.42 h′ = h. Choose a proper i 1, 2, 3, 4 so that FL Rwc ∈ { } 100 hi h′ < hi+1. Calculate R = 400   , ≤ aw 0.42 FL Rwc + = 1 + + 100 27.13 et 4 cos h′π 180° 2 3.8   [ ( / ) ] 1 Aw = 2Raw + Gaw + Baw Nbb . which is close to, but not exactly the same as, 20 ·   the eccentricity factor given in table 3. Step 1. Calculate ‘cone’ responses. Hue quadrature is computed using the for- mula R X G = M Y 100e + h h 16 H = H + i 1 ′ i B Z i +( − ) © ª © ª ei+1 h′ hi ei hi+1 h′ ­ ® ­ ® ( − ) ( − ) « ¬ « ¬ 5 and hue composition Hc is computed accord- Step 1–2*. Calculate t from C, M, or s. ing to H. If i = 3 and H = 241.2116 for exam- • If input is C or M: ple, then H is between H3 and H4 (see table 3 above). Compute P = H H = . ; L 4 58 7884 ≔ 0.25 − C M FL if input is M PR = H˘H3 = 41.2116 and round PL and PR / values to integers 59 and 41. Thus, according 0 if J = 0, ≔ to table 3, this sample is considered as having α  C  otherwise. 59% of green and 41% of blue, which is the Hc  J 100 / and can be reported as 59G41B or 41B59G.  p  Step 6*. Calculate the achromatic response • If input is s:

A ≔ p′ Nbb . s 2 A + 4 2 · α ≔ w 50 c Step 7. Calculate the correlate of   cz J ≔ 100 A Aw . Compute t from α: ( / ) Step 8. Calculate the correlate of 1 0.9 ≔ α / t .  1.64 0.29n 0 73  ≔ 4 J + 0.25 ( − ) Q Aw 4 FL . c r100( ) Step 1–3. Calculate h from H (if input is Step 9*. Calculate the correlates of chroma H). The correlate of hue (h) can be com- (C), (M), and saturation (s). puted by using data in table 3 in the forward model. Choose a proper i 1, 2, 3, 4 such 2 2 50000 13Nc Ncb et √a + b ∈ { } t ≔ / , that Hi H < Hi+1. Then u + 0.305 ≤ 0.9 n 0.73 α ≔ t 1.64 0.29 , H Hi ei+1 hi ei hi+1 100hi ei+1 ( − ) h′ = ( − )( − )− . H H e + e 100e + J i i 1 i i 1 C ≔ α , ( − )( − )− r100 Set h = h′ 360° if h′ > 360°, and h = h′ . − M ≔ C F0 25, otherwise. · L ≔ αc s 50 . Step 2*. Calculate et , A, p1′ , and p2′ r Aw + 4 1 et = cos hπ 180° + 2 + 3.8 , 4 ( ( / ) ) A.2. Inverse model 1 cz A = Aw J 100 /( ), ( / ) Step 1. Obtain J, t, and h from H, Q, C, M, s. 50000 p′ = et Nc Ncb, The input data can be different combinations 1 13 p′ = A Nbb. of perceived correlates, that is, J or Q; C, M, or 2 / s; and H or h. Hence, the following sub-steps Step 3*. Calculate a and b are needed to convert the input parameters to the parameters J, t, and h. 23 p′ + 0.305 t γ ≔ ( 2 ) , Step 1–1. Compute J from Q (if input is Q) 23p + 11t cos h + 108t sin h 1′ ( ) ( ) cQ a ≔ γ cos h , J ≔ 6.25 . ( ) 0.25 ≔ Aw + 4 F b γ sin h . ( ) L ( )

6 Step 4. Calculate Ra′ , Ga′ , and Ba′ . [4] Nico Schlömer. nschloe/colorio v0.1.0, February 2018. R 460 451 288 p a′ 1 2′ G = 460 891 261 a . a′ 1403 − − ©Ba′ ª ©460 220 6300ª © b ª ­ ® ­ − − ® ­ ® Step« 5*.¬ Calculate« Rc, Gc, and Bc, ¬ « ¬ R 1 0.42 R = R 100 27.13 a′ / c sign a′ | | . ( ) FL  400 R  − | a′ | Step 6. Calculate R, G, and B from Rc, Gc, and Bc. R = Rc DR. / Step 7. Calculate X, Y, and Z. (For the coeffi- cients of the inverse matrix, see the note at the end of the appendix B of [1].) X R = 1 Y M16− G . ©Zª ©Bª ­ ® ­ ® References« ¬ « ¬

[1] Changjun Li, Zhiqiang Li, Zhifeng Wang, Yang Xu, Ming Ronnier Luo, Guihua Cui, Manuel Melgosa, Michael H. Brill, and Michael Pointer. Comprehensive color so- lutions: CAM16, CAT16, and CAM16- UCS. Color Res. Appl., 42(6):703–718, June 2017. [2] Ming Ronnier Luo and Changjun Li. CIECAM02 and Its Recent Developments, pages 19–58. Springer New York, New York, NY, May 2012.

[3] Nathan Moroney, Mark D. Fairchild, Robert W. G. Hunt, Changjun Li, M. Ron- nier Luo, and Todd Newman. The CIECAM02 . In The Tenth Color Imaging Conference: Color Science and Engineering Systems, Technologies, Applications, CIC 2002, Scottsdale, Arizona, USA, November 12- 15, 2002, pages 23–27, 2002.

7