diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2020-06-19 23:42:16 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2020-06-19 23:42:16 +0200 |
commit | 77221e174cdab64de60450646de77f849b043062 (patch) | |
tree | 313032eb10ba2aeb2ceda2de8a141d0f8caeb8c4 /test_example.py | |
parent | 79d22b12c8c69962090ecc893aedf7195450737c (diff) |
Major cleanup
- The interpolator code is no longer here (but in the Colour fork)
- Refactoring made the code shorter and cleaner
- All tests work properly again
Diffstat (limited to 'test_example.py')
-rw-r--r-- | test_example.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/test_example.py b/test_example.py index f2e5345..6be982d 100644 --- a/test_example.py +++ b/test_example.py @@ -1,15 +1,11 @@ import numpy as np from colour import * from colour.difference import delta_E_CIE1976 -from jakob_hanika import jakob_hanika, model_sd -from test_colorchecker import plot_comparison +from colour.models import eotf_inverse_sRGB +from gsoc_common import D65, D65_xy, jakob_hanika, model_sd, plot_comparison -illuminant = "D65" -ill_xy = ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][illuminant] -ill_sd = SpectralDistribution(ILLUMINANT_SDS[illuminant]) - # These numbers are taken from Jakob and Hanika's Jupyter notebook. RGB_ref = np.array([0.79264853, 0.4, 0.63703843]) # *linear* sRGB cc_ref = np.array([ 18.70184886, -13.19804478, 2.12180137]) @@ -17,21 +13,21 @@ cc_ref = np.array([ 18.70184886, -13.19804478, 2.12180137]) if __name__ == "__main__": - XYZ = sRGB_to_XYZ(1.055 * RGB_ref ** (1/2.4) - 0.055, ill_xy) - Lab = XYZ_to_Lab(XYZ, ill_xy) + XYZ = sRGB_to_XYZ(eotf_inverse_sRGB(RGB_ref), D65_xy) + Lab = XYZ_to_Lab(XYZ, D65_xy) print("Target: X=%g, Y=%g, Z=%g, L=%g, a=%g, b=%g" % (*XYZ, *Lab)) - ccp, error = jakob_hanika(XYZ, ill_sd, ill_xy) + ccp, error = jakob_hanika(XYZ, D65, D65_xy) reference_sd = model_sd(cc_ref) - reference_XYZ = sd_to_XYZ(reference_sd, illuminant=ill_sd) - reference_Lab = XYZ_to_Lab(reference_XYZ, ill_xy) + reference_XYZ = sd_to_XYZ(reference_sd, illuminant=D65) + reference_Lab = XYZ_to_Lab(reference_XYZ, D65_xy) found_sd = model_sd(ccp) - found_XYZ = sd_to_XYZ(found_sd, illuminant=ill_sd) - found_Lab = XYZ_to_Lab(found_XYZ, ill_xy) + found_XYZ = sd_to_XYZ(found_sd, illuminant=D65) + found_Lab = XYZ_to_Lab(found_XYZ, D65_xy) print("Our results differ from the reference by ΔE = %g" \ % delta_E_CIE1976(reference_Lab, found_Lab)) - plot_comparison(XYZ, found_sd, "Reference", error, ill_sd) + plot_comparison(XYZ, found_sd, "Reference", error, D65) |