Example #1
0
def test_rgb_to_xyz():
    rgb_arr = _img()[:, 0]
    float_arr = transform.ensure_rgb_float(rgb_arr)
    xyz_arr = _nphusl._rgb_to_xyz(rgb_arr)
    for xyz, rgb, rgbf in zip(xyz_arr, rgb_arr, float_arr):
        diff = xyz - husl.rgb_to_xyz(rgbf)
        _diff(xyz, husl.rgb_to_xyz(rgbf))
Example #2
0
def test_rgb_to_xyz_3d():
    img = _img()
    float_img = transform.ensure_rgb_float(img)
    xyz_arr = _nphusl._rgb_to_xyz(img)
    for row in range(img.shape[0]):
        for col in range(img.shape[1]):
            _diff(xyz_arr[row, col], husl.rgb_to_xyz(float_img[row, col]))
Example #3
0
def test_xyz_to_luv():
    rgb_arr = _img()[:, 0]
    xyz_arr = _nphusl._rgb_to_xyz(rgb_arr)
    luv_arr = _nphusl._xyz_to_luv(xyz_arr)
    for luv, xyz in zip(luv_arr, xyz_arr):
        diff = luv - husl.xyz_to_luv(xyz)
        _diff(luv, husl.xyz_to_luv(xyz))
Example #4
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)
Example #5
0
def test_xyz_to_luv_3d():
    rgb_arr = _img()
    xyz_arr = _nphusl._rgb_to_xyz(rgb_arr)
    luv_arr = _nphusl._xyz_to_luv(xyz_arr)
    for row in range(luv_arr.shape[0]):
        for col in range(luv_arr.shape[1]):
            old_luv = husl.xyz_to_luv(xyz_arr[row, col])
            _diff(luv_arr[row, col], old_luv)
Example #6
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)
    _diff(lch_2, lch)  # just a sanity check on RGB -> LCH
    _diff(luv, luv_2)
Example #7
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 = _ref_to_lch(img[row, col])
            _diff(lch_new[row, col], lch_old)
Example #8
0
def test_luv_to_lch():
    rgb_arr = _img()[:, 14]
    float_arr = transform.ensure_rgb_float(rgb_arr)
    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(float_arr[i])
        _diff(xyz, xyz_arr[i])
        luv = husl.xyz_to_luv(xyz)
        _diff(luv, luv_arr[i])
        lch = husl.luv_to_lch(luv)
        _diff(lch, lch_arr[i])
Example #9
0
def test_luv_to_xyz():
    img = _img()
    xyz = _nphusl._rgb_to_xyz(img)
    luv = _nphusl._xyz_to_luv(xyz)
    xyz_2 = _nphusl._luv_to_xyz(luv)
    _diff(xyz_2, xyz)
Example #10
0
def test_xyz_to_rgb():
    img = ensure_float(_img())
    xyz = _nphusl._rgb_to_xyz(img)
    rgb = _nphusl._xyz_to_rgb(xyz)
    _diff(img, rgb)