示例#1
0
def test_rgb_to_lch_chain():
    rgb_arr = _img()[:, 0]
    xyz_arr = nphusl.rgb_to_xyz(rgb_arr)
    luv_arr = nphusl.xyz_to_luv(xyz_arr)
    lch_arr = nphusl.luv_to_lch(luv_arr)
    lch_arr2 = nphusl.rgb_to_lch(rgb_arr)
    assert np.all(lch_arr == lch_arr2)
示例#2
0
def test_lch_to_luv():
    img = _img()
    lch = nphusl.rgb_to_lch(img)
    luv = nphusl.lch_to_luv(lch)  # we're testing this
    xyz = nphusl.rgb_to_xyz(img)
    luv_2 = nphusl.xyz_to_luv(xyz)
    lch_2 = nphusl.luv_to_lch(luv_2)
    assert _diff(lch_2, lch)  # just a sanity check on RGB -> LCH
    assert _diff(luv, luv_2)
示例#3
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)
示例#4
0
def test_luv_to_lch():
    rgb_arr = _img()[:, 0]
    rgb_arr = _img()
    rgb_arr = rgb_arr.reshape((rgb_arr.size // 3, 3))
    xyz_arr = nphusl.rgb_to_xyz(rgb_arr)
    luv_arr = nphusl.xyz_to_luv(xyz_arr)
    lch_arr = nphusl.luv_to_lch(luv_arr)
    for i in range(rgb_arr.shape[0]):
        xyz = husl.rgb_to_xyz(rgb_arr[i])
        assert _diff(xyz, xyz_arr[i])
        luv = husl.xyz_to_luv(xyz)
        assert _diff(luv, luv_arr[i])
        lch = husl.luv_to_lch(luv)
        assert _diff(lch, lch_arr[i])