How to use the colorio.illuminants.whitepoints_cie1931 function in colorio

To help you get started, we’ve selected a few colorio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / colorio / test / test_srgb.py View on Github external
def test_whitepoint():
    srgb_linear = colorio.SrgbLinear()
    val = srgb_linear.to_xyz100([1.0, 1.0, 1.0])
    d65_whitepoint = colorio.illuminants.whitepoints_cie1931["D65"]
    assert numpy.all(numpy.abs(val - d65_whitepoint) < 1.0e-12)
    return
github nschloe / colorio / test / test_comparisons.py View on Github external
def test_from():
    """Compare colorio with colorspacius and colour.
    """
    xyz = 100 * numpy.random.rand(3)

    Y_b = 20
    whitepoint = colorio.illuminants.whitepoints_cie1931["D65"]
    L_A = 64 / numpy.pi / 5

    c = 0.69  # average
    cs2 = colorio.CIECAM02(c, Y_b, L_A)
    J, C, H, h, M, s, Q = cs2.from_xyz100(xyz)

    # compare with colorspacious
    cs1 = colorspacious.ciecam02.CIECAM02Space(
        whitepoint, Y_b, L_A, surround=colorspacious.CIECAM02Surround.AVERAGE
    )
    ref1 = cs1.XYZ100_to_CIECAM02(xyz)
    assert abs(ref1.J - J) < 1.0e-14 * J
    assert abs(ref1.C - C) < 1.0e-14 * C
    assert abs(ref1.H - H) < 1.0e-14 * H
    assert abs(ref1.h - h) < 1.0e-14 * h
    assert abs(ref1.M - M) < 1.0e-14 * M
github nschloe / colorio / test / test_cam16.py View on Github external
def test_whitepoint():
    # With infinite luminance of the adapting field, the whitepoint is found
    # at (100, 0, 0).
    L_A = numpy.inf
    cam16 = colorio.CAM16UCS(0.69, 20, L_A)
    out = cam16.from_xyz100(colorio.illuminants.whitepoints_cie1931["D65"])
    assert numpy.all(out == [100, 0, 0])
    return
github nschloe / colorio / colorio / _ciecam02.py View on Github external
    def __init__(self, c, Y_b, L_A, whitepoint=whitepoints_cie1931["D65"]):
        # step0: Calculate all values/parameters which are independent of input
        #        samples
        Y_w = whitepoint[1]

        # Nc and F are modelled as a function of c, and can be linearly interpolated.
        c_vals = [0.525, 0.59, 0.69]
        F_Nc_vals = [0.8, 0.9, 1.0]
        assert 0.535 <= c <= 0.69
        F = numpy.interp(c, c_vals, F_Nc_vals)
        self.c = c
        self.N_c = F

        self.M_cat02 = numpy.array(
            [
                [+0.7328, +0.4296, -0.1624],
                [-0.7036, +1.6975, +0.0061],
github nschloe / colorio / colorio / _jzazbz.py View on Github external
    def __init__(self, whitepoint=whitepoints_cie1931["D65"]):
        self.whitepoint = whitepoint

        self.b = 1.15
        self.g = 0.66
        self.c1 = 3424 / 2 ** 12
        self.c2 = 2413 / 2 ** 7
        self.c3 = 2392 / 2 ** 7
        self.n = 2610 / 2 ** 14
        self.p = 1.7 * 2523 / 2 ** 5
        self.d = -0.56
        self.d0 = 1.6295499532821566e-11

        self.M1 = numpy.array(
            [
                [0.41478972, 0.579999, 0.0146480],
                [-0.2015100, 1.120649, 0.0531008],
github nschloe / colorio / colorio / _osa.py View on Github external
    def __init__(self, whitepoint=whitepoints_cie1931["D65"]):
        self.labels = ["L", "g", "j"]

        self.M = numpy.array(
            [
                [+0.7990, 0.4194, -0.1648],
                [-0.4493, 1.3265, +0.0927],
                [-0.1149, 0.3394, +0.7170],
            ]
        )
        self.Minv = numpy.linalg.inv(self.M)
        return
github nschloe / colorio / colorio / _cieluv.py View on Github external
    def __init__(self, whitepoint=whitepoints_cie1931["D65"]):
        self.whitepoint = whitepoint
        self.labels = ["L*", "u*", "v*"]
        self.k0 = 0  # the index that corresponds to luminosity
        return
github nschloe / colorio / colorio / _srgb.py View on Github external
def __init__(self, whitepoint_correction=True):
        # The standard actually gives the values in terms of M, but really inv(M) is a
        # direct derivative of the primary specification at
        # .
        primaries_xyy = numpy.array(
            [[0.64, 0.33, 0.2126], [0.30, 0.60, 0.7152], [0.15, 0.06, 0.0722]]
        )
        self.invM = _xyy_to_xyz100(primaries_xyy.T)

        if whitepoint_correction:
            # The above values are given only approximately, resulting in the fact that
            # SRGB(1.0, 1.0, 1.0) is only approximately mapped into the reference
            # whitepoint D65. Add a correction here.
            correction = whitepoints_cie1931["D65"] / numpy.sum(self.invM, axis=1)
            self.invM = (self.invM.T * correction).T

        self.invM /= 100

        # numpy.linalg.inv(self.invM) is the matrix in the spec:
        # M = numpy.array([
        #     [+3.2406255, -1.537208, -0.4986286],
        #     [-0.9689307, +1.8757561, +0.0415175],
        #     [+0.0557101, -0.2040211, +1.0569959],
        # ])
        # self.invM = numpy.linalg.inv(M)
        self.labels = ["R", "G", "B"]
        return
github nschloe / colorio / colorio / _cielab.py View on Github external
    def __init__(self, whitepoint=whitepoints_cie1931["D65"]):
        self.whitepoint = whitepoint
        self.labels = ["L*", "a*", "b*"]
        self.k0 = 0  # the index that corresponds to luminosity
        return
github nschloe / colorio / colorio / _rlab.py View on Github external
def __init__(
        self, Y_n=318.0, D=0.0, whitepoint=whitepoints_cie1931["D65"], sigma=1.0 / 2.3
    ):
        # One purpose of RLAB is to account for the adaptation in the human visual
        # system. That is, the visual system sees a red apple no matter if it is looked
        # at in bright daylight, at dawn, or in the light of a fire.  To achieve this,
        # RLAB first converts a tristimulus value XYZ into a tristimulus value under the
        # reference illuminant D65.

        # M_HPE, normalized to D65:
        # M_HPE, normalized to equal-energy illuminant,
        # .
        self.M = numpy.array(
            [[0.3897, 0.6890, -0.0787], [-0.2298, 1.1834, 0.0464], [0.0, 0.0, 1.0]]
        )

        lms_n = self.M @ whitepoint
        lms_e = 3.0 * lms_n / numpy.sum(lms_n)