summaryrefslogtreecommitdiff
path: root/test_error_function.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_error_function.py')
-rw-r--r--test_error_function.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test_error_function.py b/test_error_function.py
new file mode 100644
index 0000000..99e1268
--- /dev/null
+++ b/test_error_function.py
@@ -0,0 +1,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),))