|
10 | 10 | from functools import wraps as _wraps, partial as _partial # unexport, see #17 |
11 | 11 | import math as _math # unexport, see #17 |
12 | 12 |
|
| 13 | +# XYZ-to-sRGB matrix |
13 | 14 | _m = [[3.240969941904521, -1.537383177570093, -0.498610760293], |
14 | 15 | [-0.96924363628087, 1.87596750150772, 0.041555057407175], |
15 | 16 | [0.055630079696993, -0.20397695888897, 1.056971514242878]] |
16 | | -_min_v = [[0.41239079926595, 0.35758433938387, 0.18048078840183], |
| 17 | +# sRGB-to-XYZ matrix |
| 18 | +_m_inv = [[0.41239079926595, 0.35758433938387, 0.18048078840183], |
17 | 19 | [0.21263900587151, 0.71516867876775, 0.072192315360733], |
18 | 20 | [0.019330818715591, 0.11919477979462, 0.95053215224966]] |
19 | 21 | _ref_y = 1.0 |
20 | 22 | _ref_u = 0.19783000664283 |
21 | 23 | _ref_v = 0.46831999493879 |
22 | | -_kappa = 903.2962962 |
23 | | -_epsilon = 0.0088564516 |
| 24 | +_kappa = 903.2962962 # 24389/27 == (29/3)**3 |
| 25 | +_epsilon = 0.0088564516 # 216/24389 == (6/29)**3 |
24 | 26 |
|
25 | 27 |
|
26 | 28 | def _normalize_output(conversion): |
@@ -124,9 +126,9 @@ def rgb_to_xyz(_hx_tuple): |
124 | 126 | rgbl = (_to_linear(_hx_tuple[0]), |
125 | 127 | _to_linear(_hx_tuple[1]), |
126 | 128 | _to_linear(_hx_tuple[2])) |
127 | | - return (_dot_product(_min_v[0], rgbl), |
128 | | - _dot_product(_min_v[1], rgbl), |
129 | | - _dot_product(_min_v[2], rgbl)) |
| 129 | + return (_dot_product(_m_inv[0], rgbl), |
| 130 | + _dot_product(_m_inv[1], rgbl), |
| 131 | + _dot_product(_m_inv[2], rgbl)) |
130 | 132 |
|
131 | 133 |
|
132 | 134 | def xyz_to_luv(_hx_tuple): |
|
0 commit comments