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) assert _diff(luv, husl.xyz_to_luv(xyz))
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)
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]) assert _diff(luv_arr[row, col], old_luv)
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)
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)
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])
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) assert _diff(xyz_2, xyz)