1 # Check conversion of RGB colors to CIE Lch color space
3 # Samples are obtained (with Ref. White D65, Gamma = 1 for linear RGB) using
4 # http://brucelindbloom.com/index.html?ColorCalculator.html
5 # Note that for c = 0 we have h = 0 (not 270 as in the above link)
6 set rgb_to_lch_samples {
7 { # black, white, 50% gray }
10 { {0.5 0.5 0.5} {76.0693 0 0} }
13 { {1 0 0} {53.2408 104.5518 39.9990} }
14 { {0 1 0} {87.7347 119.7759 136.0160} }
15 { {0 0 1} {32.2970 133.8076 306.2849} }
16 { {0 1 1} {91.1132 50.1209 196.3762} }
17 { {1 1 0} {97.1393 96.9054 102.8512} }
18 { {1 0 1} {60.3242 115.5407 328.2350} }
20 { # shades of pure red }
21 { {0.1 0 0} {16.1387 44.8334 33.9838} }
22 { {0.3 0 0} {30.3521 69.3816 39.3960} }
23 { {0.5 0 0} {38.9565 82.9828 39.9990} }
24 { {0.7 0 0} {45.4792 92.8320 39.9990} }
25 { {0.9 0 0} {50.8512 100.9436 39.9990} }
28 { {0.3 0.5 0.9} {75.2228 31.8514 271.3601} }
31 foreach sample $rgb_to_lch_samples {
32 set rgb [lindex $sample 0]
33 if { $rgb == "#" } continue
35 set ref [lindex $sample 1]
36 set lch [vcolorconvert to lch {*}$rgb]
37 check3reals "RGB ($rgb) to Lch" {*}$lch {*}$ref 1e-4