summaryrefslogtreecommitdiff
path: root/test_interpolator.py
blob: ba476da8b9db641a7abe856550e907b5aaaa08b7 (plain)
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
import numpy as np, struct
from colour import *
from colour.difference import delta_E_CIE1976
from colour.models import eotf_inverse_sRGB
from colour.recovery import Jakob2019Interpolator
from gsoc_common import *


# This script tests if the interpolator correctly handles multi-dimensional
# inputs.
if __name__ == "__main__":
    interp = Jakob2019Interpolator()
    interp.from_file("data/srgb.coeff")

    RGBs = np.random.random((7, 6, 5, 4, 3))
    ccs = interp.coefficients(RGBs)

    RGB = eotf_inverse_sRGB(RGBs[0, 0, 0, 0, :])
    XYZ = sRGB_to_XYZ(RGB)
    Lab = XYZ_to_Lab(XYZ, D65_xy)
    cc = ccs[0, 0, 0, 0, :]

    matched_sd = model_sd(cc, primed=False)
    matched_XYZ = sd_to_XYZ(matched_sd, illuminant=D65) / 100
    matched_Lab = XYZ_to_Lab(matched_XYZ, D65_xy)
    error = delta_E_CIE1976(Lab, matched_Lab)

    plot_comparison(XYZ, matched_sd, "Model", error, D65)