Ejemplo n.º 1
0
def test_rgb_to_lch_3d():
    rgb_arr = _img()
    lch_arr = nphusl.rgb_to_lch(rgb_arr)
    for row in range(lch_arr.shape[0]):
        for col in range(lch_arr.shape[1]):
            old_lch = husl.rgb_to_lch(*rgb_arr[row, col])
            assert _diff(lch_arr[row, col], old_lch)
Ejemplo n.º 2
0
def test_luv_to_lch_3d():
    img = _img()
    xyz_arr = nphusl.rgb_to_xyz(img)
    luv_arr = nphusl.xyz_to_luv(xyz_arr)
    lch_new = nphusl.luv_to_lch(luv_arr)
    for row in range(lch_new.shape[0]):
        for col in range(lch_new.shape[1]):
            lch_old = husl.rgb_to_lch(*img[row, col])
            assert _diff(lch_new[row, col], lch_old)
Ejemplo n.º 3
0
def test_lch_to_husl_3d():
    img = _img()
    lch_new = nphusl.rgb_to_lch(img)
    hsl_new = nphusl.lch_to_husl(lch_new)
    for row in range(lch_new.shape[0]):
        for col in range(lch_new.shape[1]):
            lch_old = husl.rgb_to_lch(*img[row, col])
            assert _diff(lch_old, lch_new[row, col])
            hsl_old = husl.lch_to_husl(lch_old)
            assert _diff(hsl_new[row, col], hsl_old)
Ejemplo n.º 4
0
def test_lch_to_husl():
    rgb_arr = _img()
    lch_arr = nphusl.rgb_to_lch(rgb_arr)
    hsl_from_lch_arr = nphusl.lch_to_husl(lch_arr)
    hsl_from_rgb_arr = nphusl.rgb_to_husl(rgb_arr)
    print(rgb_arr[30:34, 0])
    print(hsl_from_lch_arr[30:34, 0])
    print(hsl_from_rgb_arr[30:34, 0])
    for i in range(rgb_arr.shape[0]):
        old_lch = husl.rgb_to_lch(*rgb_arr[i, 0])
        hsl_old = husl.lch_to_husl(old_lch)
        hsl_old = husl.rgb_to_husl(*rgb_arr[i, 0])
        assert _diff(lch_arr[i, 0], old_lch)
        assert _diff_hue(hsl_from_lch_arr[i, 0], hsl_from_rgb_arr[i, 0])
        assert _diff_hue(hsl_from_lch_arr[i, 0], hsl_from_rgb_arr[i, 0])
Ejemplo n.º 5
0
def test_rgb_to_lch():
    rgb_arr = _img()[:, 0]
    lch_arr = nphusl.rgb_to_lch(rgb_arr)
    for lch, rgb in zip(lch_arr, rgb_arr):
        diff = lch - husl.rgb_to_lch(*rgb)
        assert _diff(lch, husl.rgb_to_lch(*rgb))
Ejemplo n.º 6
0
def _ref_to_lch(rgb):
    asfloat = (c / 255.0 for c in rgb)
    return husl.rgb_to_lch(*asfloat)