def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3) # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "luv_array_{0}_{1}.npy".format(I, obs) luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), "data", fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["a", "e"]: fname = "luv_array_{0}_2.npy".format(I, obs) luv_array_I_obs = np.load(os.path.join(os.path.dirname(__file__), "data", fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, "2"), self.xyz_array, decimal=3)
def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3) # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "color/tests/data/luv_array_{0}_{1}.npy".format(I, obs) luv_array_I_obs = np.load(fetch(fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["a", "e"]: fname = "color/tests/data/luv_array_{0}_2.npy".format(I, obs) luv_array_I_obs = np.load(fetch(fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, "2"), self.xyz_array, decimal=3)
def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3) # Test the conversion with the rest of the illuminants. for I in ["d50", "d55", "d65", "d75"]: for obs in ["2", "10"]: fname = "luv_array_{0}_{1}.npy".format(I, obs) luv_array_I_obs = np.load( os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["a", "e"]: fname = "luv_array_{0}_2.npy".format(I, obs) luv_array_I_obs = np.load( os.path.join(os.path.dirname(__file__), 'data', fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, "2"), self.xyz_array, decimal=3)
def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3) # Test the conversion with the rest of the illuminants. for I in ["A", "B", "C", "d50", "d55", "d65"]: I = I.lower() for obs in ["2", "10", "R"]: obs = obs.lower() fname = f'color/tests/data/luv_array_{I}_{obs}.npy' luv_array_I_obs = np.load(fetch(fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, obs), self.xyz_array, decimal=3) for I in ["d75", "e"]: fname = f'color/tests/data/luv_array_{I}_2.npy' luv_array_I_obs = np.load(fetch(fname)) assert_array_almost_equal(luv2xyz(luv_array_I_obs, I, "2"), self.xyz_array, decimal=3)
def test_luv2xyz_dtype(self): img = self.luv_array.astype('float64') img32 = img.astype('float32') assert luv2xyz(img).dtype == img.dtype assert luv2xyz(img32).dtype == img32.dtype
def test_luv2xyz(self): assert_array_almost_equal(luv2xyz(self.luv_array), self.xyz_array, decimal=3)
def test_luv2xyz_channel_axis(self, channel_axis): # test conversion with channels along a specified axis luv = np.moveaxis(self.luv_array, source=-1, destination=channel_axis) xyz = luv2xyz(luv, channel_axis=channel_axis) xyz = np.moveaxis(xyz, source=channel_axis, destination=-1) assert_array_almost_equal(xyz, self.xyz_array, decimal=3)
def to_xyz_from_luv(self): return Image(luv2xyz(self)).convert_type(self.dtype)