How to use the colorio.CAM16 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_comparisons.py View on Github external
def performance_comparison_to():
    import perfplot

    Y_b = 20
    L_A = 64 / numpy.pi / 5

    c = 0.69  # average
    cam16 = colorio.CAM16(c, Y_b, L_A)

    def cio(x):
        return cam16.to_xyz100(x, "JCh")

    cam16_legacy = CAM16Legacy(c, Y_b, L_A)

    def cio_legacy(x):
        return cam16_legacy.to_xyz100(x, "JCh")

    perfplot.plot(
        setup=lambda n: numpy.random.rand(3, n),
        kernels=[cio, cio_legacy],
        n_range=100000 * numpy.arange(11),
        xlabel="Number of input samples",
    )
github nschloe / colorio / test / test_cam16.py View on Github external
def test_zero(xyz):
    L_A = 64 / numpy.pi / 5
    cam16 = colorio.CAM16(0.69, 20, L_A)
    J, C, H, h, M, s, Q = cam16.from_xyz100(xyz)

    assert numpy.all(J == 0.0)
    assert numpy.all(C == 0.0)
    assert numpy.all(h == 0.0)
    assert numpy.all(M == 0.0)
    assert numpy.all(s == 0.0)
    assert numpy.all(Q == 0.0)

    out = cam16.to_xyz100(numpy.array([J, C, H]), "JCH")
    assert numpy.all(abs(out) < 1.0e-13)

    out = cam16.to_xyz100(numpy.array([Q, M, h]), "QMh")
    assert numpy.all(abs(out) < 1.0e-13)

    out = cam16.to_xyz100(numpy.array([J, s, h]), "Jsh")
github nschloe / colorio / test / test_comparisons.py View on Github external
def performance_comparison_from():
    import perfplot

    def setup(n):
        out = numpy.empty((3, n))
        rgb = numpy.random.rand(3)
        for k in range(3):
            out[k] = rgb[k]
        return out

    Y_b = 20
    L_A = 64 / numpy.pi / 5
    c = 0.69  # average
    cam16 = colorio.CAM16(c, Y_b, L_A)

    cam16_legacy = CAM16Legacy(c, Y_b, L_A)

    perfplot.show(
        setup=setup,
        kernels=[cam16.from_xyz100, cam16_legacy.from_xyz100],
        labels=["new", "legacy"],
        n_range=1000 * numpy.arange(6),
        equality_check=False,
    )
    return
github nschloe / colorio / test / test_comparisons.py View on Github external
def test_0():
    Y_b = 20
    L_A = 64 / numpy.pi / 5
    c = 0.69  # average
    cam16 = colorio.CAM16(c, Y_b, L_A)

    xyz = numpy.zeros(3)
    J, C, _, h, M, s, Q = cam16.from_xyz100(xyz)

    assert J == 0.0
    assert C == 0.0
    assert h == 0.0
    assert M == 0.0
    assert s == 0.0
    assert Q == 0.0

    # Comparison with other schemes
    cam16_legacy = CAM16Legacy(c, Y_b, L_A)
    ref2 = cam16_legacy.from_xyz100(xyz)
    print(ref2)
    return
github nschloe / colorio / test / test_cam16.py View on Github external
def test_conversion(xyz):
    # test with srgb conditions
    L_A = 64 / numpy.pi / 5
    cam16 = colorio.CAM16(0.69, 20, L_A)
    J, C, H, h, M, s, Q = cam16.from_xyz100(xyz)

    out = cam16.to_xyz100(numpy.array([J, C, H]), "JCH")
    assert numpy.all(abs(xyz - out) < 1.0e-13 * abs(xyz))

    out = cam16.to_xyz100(numpy.array([Q, M, h]), "QMh")
    assert numpy.all(abs(xyz - out) < 1.0e-13 * abs(xyz))

    out = cam16.to_xyz100(numpy.array([J, s, h]), "Jsh")
    assert numpy.all(abs(xyz - out) < 1.0e-13 * abs(xyz))
    return