def test_degree_of_adaptation(): assert_almost_equal(CIECAM02._compute_degree_of_adaptation(1, 100), 0.940656, decimal=6) assert_almost_equal(CIECAM02._compute_degree_of_adaptation(1, 318.31), 0.9994, decimal=2) assert_almost_equal(CIECAM02._compute_degree_of_adaptation(1, 31.83), 0.875, decimal=2)
def create_model_from_data(self, data): return CIECAM02( data["X"], data["Y"], data["Z"], data["X_W"], data["Y_W"], data["Z_W"], data["Y_b"], data["L_A"], data["c"], data["N_c"], data["F"], )
def rgb_to_cbh(self, r, g, b): target_xyz = convert_color(sRGBColor(r, g, b, is_upscaled=True), XYZColor) perception = CIECAM02( target_xyz.xyz_x, target_xyz.xyz_y, target_xyz.xyz_z, REFERENCE_WHITE.xyz_x, REFERENCE_WHITE.xyz_y, REFERENCE_WHITE.xyz_z, c=0.69, n_c=1, f=1, # I do not know what these parameters mean l_a=self.ambient_lightness, y_b=self.background_brightness, ) return perception.chroma, perception.brightness, perception.hue_angle
def test_xyz_to_rgb(): assert_almost_equal(CIECAM02._xyz_to_rgb( numpy.array([95.05, 100, 108.9])), numpy.array([94.9273, 103.527, 108.737]), decimal=2)
def create_model_from_data(self, data): return CIECAM02(data['X'], data['Y'], data['Z'], data['X_W'], data['Y_W'], data['Z_W'], data['Y_b'], data['L_A'], data['c'], data['N_c'], data['F'])
def test_xyz_to_rgb(): assert_almost_equal(CIECAM02._xyz_to_rgb(numpy.array([95.05, 100, 108.9])), numpy.array([94.9273, 103.527, 108.737]), decimal=2)
# Adapting luminance l_a = 328.31 # Surround condition assumed to be average (see CIECAM02 documentation for values) c = 0.69 n_c = 1 f = 1 model_a = CIECAM02( color.xyz_x, color.xyz_y, color.xyz_z, illuminant_d65.xyz_x, illuminant_d65.xyz_y, illuminant_d65.xyz_z, y_b_dark, l_a, c, n_c, f, ) model_b = CIECAM02( color.xyz_x, color.xyz_y, color.xyz_z, illuminant_d65.xyz_x, illuminant_d65.xyz_y, illuminant_d65.xyz_z, y_b_light, l_a,