How to use the colorio.CIELAB 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_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_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"),
github nschloe / colorio / test / test_tools.py View on Github external
def test_show_straights(cs=colorio.CIELAB()):
    colorio.show_straights(cs)
github nschloe / colorio / test / test_cielab.py View on Github external
def test_conversion(xyz):
    cielab = colorio.CIELAB()
    out = cielab.to_xyz100(cielab.from_xyz100(xyz))
    assert numpy.all(abs(xyz - out) < 1.0e-14)
    return
github nschloe / cplot / cplot / main.py View on Github external
rd = r0 - r0 * 2 * abs(absval_scaled - 0.5)
        cam_pts = numpy.array(
            [
                100 * absval_scaled,
                rd * numpy.cos(angle + offset),
                rd * numpy.sin(angle + offset),
            ]
        )
        # now just translate to srgb
        srgb_vals = srgb.to_srgb1(srgb.from_xyz100(cam.to_xyz100(cam_pts)))
        # Cut off the outliers. This restriction makes the representation less perfect,
        # but that's what it is with the SRGB color space.
        srgb_vals[srgb_vals > 1] = 1.0
        srgb_vals[srgb_vals < 0] = 0.0
    elif colorspace.upper() == "CIELAB":
        cielab = colorio.CIELAB()
        srgb = colorio.SrgbLinear()
        # The max radius is about 29.5, but crank up colors a little bit to make the
        # images more saturated. This leads to SRGB-cut-off of course.
        # r0 = find_max_srgb_radius(cielab, srgb, L=50)
        # r0 = 29.488203674554825
        r0 = 45.0
        # Rotate the angles such a "green" color represents positive real values. The
        # rotation is chosen such that the ratio g/(r+b) (in rgb) is the largest for the
        # point 1.0.
        offset = 0.893_686_8 * numpy.pi
        # Map (r, angle) to a point in the color space; bicone mapping similar to what
        # HSL looks like .
        rd = r0 - r0 * 2 * abs(absval_scaled - 0.5)
        lab_pts = numpy.array(
            [
                100 * absval_scaled,