1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import numpy as np
from colour import *
from colour.recovery import error_function_Jakob2019
from gsoc_common import model_sd, D65_xy
if __name__ == "__main__":
shape = SpectralShape(360, 830, 1)
cmfs = STANDARD_OBSERVER_CMFS["CIE 1931 2 Degree Standard Observer"].align(shape)
illuminant = SpectralDistribution(ILLUMINANT_SDS["D65"]).align(shape)
illuminant_XYZ = sd_to_XYZ(illuminant) / 100
coefficients = np.array([8.70184886, -13.19804478, 2.12180137])
target = np.array([20, 50, 30])
error, derror_dc, R, XYZ, Lab = error_function_Jakob2019(
coefficients, target, shape, cmfs,
illuminant, illuminant_XYZ, True
)
sd = model_sd(coefficients)
good_XYZ = sd_to_XYZ(sd, illuminant=illuminant)
good_Lab = XYZ_to_Lab(good_XYZ / 100, D65_xy)
print("Good XYZ: %g %g %g" % (*good_XYZ,))
print(" EF XYZ: %g %g %g" % (*XYZ,))
print("Good Lab: %g %g %g" % (*good_Lab,))
print(" EF Lab: %g %g %g" % (*Lab,))
print(" EF* Lab: %g %g %g" % (*XYZ_to_Lab(XYZ / 100, D65_xy),))
|