How to use colorio - 10 common examples

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_tools.py View on Github external
def test_xy_gamut_mesh():
    points, cells = colorio.xy_gamut_mesh(0.05)

    # import meshio
    # meshio.write_points_cells("test.vtu", points, {"triangle": cells})
    # exit(1)


if __name__ == "__main__":
    # test_luo_rigg()
    # test_xy_gamut_mesh()
    # test_macadam()
    # colorspace_ = colorio.SrgbLinear()
    # colorspace_ = colorio.Hdr()
    # colorspace_ = colorio.XYZ()
    colorspace_ = colorio.XYY()
    # colorspace_ = colorio.IPT()
    # colorspace_ = colorio.JzAzBz()
    # colorspace_ = colorio.CIELUV()
    # colorspace_ = colorio.CIELAB()
    # colorspace_ = colorio.CAM02('UCS', 0.69, 20, 64/numpy.pi/5)
    # colorspace_ = colorio.CAM16UCS(0.69, 20, 64 / numpy.pi / 5)
    # test_hdr_gamut(colorspace_, n=10)
    # test_visible_gamut(colorspace_, cut_000=False)
    # test_srgb_gamut(colorspace_, cut_000=False)
    # test_ebner_fairchild(colorspace_)
    test_hung_berns(colorspace_)
    # test_xiao(colorspace_)
github nschloe / colorio / test / test_illuminants.py View on Github external
def test_spectrum_to_xyz100():
    spectrum = colorio.illuminants.d65()
    observer = colorio.observers.cie_1931_2()
    colorio.illuminants.spectrum_to_xyz100(spectrum, observer)
    return
github nschloe / colorio / test / test_osa.py View on Github external
def test_speed(N=2):
    numpy.random.seed(1)
    osa = colorio.OsaUcs()
    cielab = colorio.CIELAB()
    # cam16 = colorio.CAM16(0.69, 20, L_A=64 / numpy.pi / 5)
    ciecam02 = colorio.CIECAM02(0.69, 20, L_A=64 / numpy.pi / 5)

    # This close probably means that another figure hasn't been properly closed.
    import matplotlib.pyplot as plt
    plt.close()

    perfplot.show(
        # Don't use numpy.random.rand(3, n) to avoid the CIECAM breakdown
        setup=lambda n: numpy.outer(numpy.random.rand(3), numpy.ones(n)) * 10,
        equality_check=None,
        kernels=[
            osa.to_xyz100,
            cielab.to_xyz100,
            # cam16.to_xyz100,
            lambda Jsh: ciecam02.to_xyz100(Jsh, "Jsh"),
            numpy.cbrt,
        ],
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
    assert abs(ref1.s - s) < 1.0e-14 * s
    assert abs(ref1.Q - Q) < 1.0e-14 * Q

    # compare with color
github nschloe / colorio / test / test_ciecam02.py View on Github external
[
            # J, C, H, h, M, s, Q
            48.0314,
            38.7789,
            240.8885,
            191.0452,
            38.7789,
            46.0177,
            183.1240,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-6 * reference_values)

    # different L_A
    xyz = [19.31, 23.93, 10.14]
    ciecam02 = colorio.CIECAM02(0.69, 18, 20, whitepoint=[98.88, 90, 32.03])
    values = ciecam02.from_xyz100(xyz)
    reference_values = numpy.array(
        [
            # J, C, H, h, M, s, Q
            47.6856,
            36.0527,
            232.6630,
            185.3445,
            29.7580,
            51.1275,
            113.8401,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-5 * reference_values)

    # gold values from Mark Fairchild's spreadsheet at
github nschloe / colorio / test / test_ciecam02.py View on Github external
# J, C, H, h, M, s, Q
            47.6856,
            36.0527,
            232.6630,
            185.3445,
            29.7580,
            51.1275,
            113.8401,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-5 * reference_values)

    # gold values from Mark Fairchild's spreadsheet at
    #   http://rit-mcsl.org/fairchild//files/AppModEx.xls
    xyz = [19.01, 20.00, 21.78]
    ciecam02 = colorio.CIECAM02(
        0.69, 20, 318.30988618379, whitepoint=[95.05, 100.0, 108.88]
    )
    values = ciecam02.from_xyz100(xyz)
    reference_values = numpy.array(
        [
            # J, C, H, h, M, s, Q
            4.17310911e01,
            1.04707861e-01,
            2.78060724e02,
            2.19048423e02,
            1.08842280e-01,
            2.36030659e00,
            1.95371311e02,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-8 * reference_values)
github nschloe / colorio / test / test_ciecam02.py View on Github external
reference_values = numpy.array(
        [
            # J, C, H, h, M, s, Q
            4.17310911e01,
            1.04707861e-01,
            2.78060724e02,
            2.19048423e02,
            1.08842280e-01,
            2.36030659e00,
            1.95371311e02,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-8 * reference_values)

    xyz = [57.06, 43.06, 31.96]
    ciecam02 = colorio.CIECAM02(
        0.69, 20, 31.830988618379, whitepoint=[95.05, 100.0, 108.88]
    )
    values = ciecam02.from_xyz100(xyz)
    reference_values = numpy.array(
        [
            # J, C, H, h, M, s, Q
            65.95523,
            48.57050,
            399.38837,
            19.55739,
            41.67327,
            52.24549,
            152.67220,
        ]
    )
    assert numpy.all(abs(values - reference_values) < 1.0e-6 * reference_values)
github nschloe / colorio / test / test_ciecam02.py View on Github external
def test_breakdown():
    bad_xyz = [8.71292997, 2.02183974, 83.26198455]
    ciecam02 = colorio.CIECAM02(0.69, 20, L_A=64 / numpy.pi / 5)
    with pytest.raises(colorio.NegativeAError):
        ciecam02.from_xyz100(bad_xyz)
    return
github nschloe / colorio / test / test_cielab.py View on Github external
def test_macadams():
    cielab = colorio.CIELAB()
    cielab.plot_macadams(0, 50)
    # cieluv = colorio.CIELUV()
    # cieluv.plot_macadams(0, 30)
    # xyy = colorio.XYY()
    # xyy.plot_macadams(1.5, k0=2)
    return
github nschloe / colorio / test / test_tools.py View on Github external
    "colorspace", [colorio.CIELAB(), colorio.CAM02("UCS", 0.69, 20, 64 / numpy.pi / 5)]
)
def test_hdr_gamut(colorspace, n=10):
    colorspace.save_hdr_gamut("hdr.vtu", n=n)