def test_n_dimensional_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition n-dimensional arrays support. """ RGB = np.array([0.45620519, 0.03081071, 0.04091952]) YcCbcCrc = RGB_to_YcCbcCrc(RGB) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7)
def test_n_dimensional_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition n-dimensional arrays support. """ RGB = np.array([0.75, 0.5, 0.25]) YcCbcCrc = np.array([0.69738693, 0.38700523, 0.61084888]) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7) RGB = np.tile(RGB, 4) RGB = np.reshape(RGB, (4, 4, 4, 3)) YcCbcCrc = np.tile(YcCbcCrc, 4) YcCbcCrc = np.reshape(YcCbcCrc, (4, 4, 4, 3)) np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB), YcCbcCrc, decimal=7)
def test_domain_range_scale_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.prismatic.RGB_to_YcCbcCrc` definition domain and range scale support. """ RGB = np.array([0.45620519, 0.03081071, 0.04091952]) YcCbcCrc = RGB_to_YcCbcCrc(RGB) d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_almost_equal(RGB_to_YcCbcCrc(RGB * factor), YcCbcCrc * factor, decimal=7)
def test_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition. """ np.testing.assert_almost_equal( RGB_to_YcCbcCrc(np.array([0.45620519, 0.03081071, 0.04091952])), np.array([0.37020379, 0.41137200, 0.77704674]), decimal=7) np.testing.assert_almost_equal(RGB_to_YcCbcCrc( np.array([0.18, 0.18, 0.18]), out_bits=10, out_legal=True, out_int=True, is_12_bits_system=False), np.array([422, 512, 512]), decimal=7)
def test_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition. """ np.testing.assert_almost_equal( RGB_to_YcCbcCrc(np.array([0.123, 0.456, 0.789])), np.array([0.59258892, 0.64993099, 0.35269847]), decimal=7) np.testing.assert_almost_equal(RGB_to_YcCbcCrc( np.array([0.18, 0.18, 0.18]), out_bits=10, out_legal=True, out_int=True, is_12_bits_system=False), np.array([422, 512, 512]), decimal=7)
def test_nan_RGB_to_YcCbcCrc(self): """ Tests :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition nan support. """ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: RGB = np.array(case) RGB_to_YcCbcCrc(RGB)