Esempio n. 1
0
    def test_YCbCr_to_RGB(self):
        """
        Tests :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition.
        """

        np.testing.assert_almost_equal(YCbCr_to_RGB(
            np.array([0.66035745, 0.17254902, 0.53216593])),
                                       np.array([0.75, 0.75, 0.0]),
                                       decimal=7)

        np.testing.assert_almost_equal(
            YCbCr_to_RGB(np.array([471, 650, 390]),
                         in_bits=10,
                         in_legal=True,
                         in_int=True),
            np.array([0.25018598, 0.49950072, 0.75040741]),
            decimal=7)

        np.testing.assert_almost_equal(YCbCr_to_RGB(np.array([150, 99, 175]),
                                                    in_bits=8,
                                                    in_legal=False,
                                                    in_int=True,
                                                    out_bits=8,
                                                    out_legal=True,
                                                    out_int=True),
                                       np.array([208, 131, 99]),
                                       decimal=7)
Esempio n. 2
0
    def test_n_dimensional_YCbCr_to_RGB(self):
        """
        Tests :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition
        n-dimensional arrays support.
        """

        YCbCr = np.array([0.52230157, 0.36699593, 0.62183309])
        RGB = YCbCr_to_RGB(YCbCr)

        RGB = np.tile(RGB, 4)
        RGB = np.reshape(RGB, (4, 3))
        YCbCr = np.tile(YCbCr, 4)
        YCbCr = np.reshape(YCbCr, (4, 3))
        np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB)

        RGB = np.tile(RGB, 4)
        RGB = np.reshape(RGB, (4, 4, 3))
        YCbCr = np.tile(YCbCr, 4)
        YCbCr = np.reshape(YCbCr, (4, 4, 3))
        np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB)

        RGB = np.tile(RGB, 4)
        RGB = np.reshape(RGB, (4, 4, 4, 3))
        YCbCr = np.tile(YCbCr, 4)
        YCbCr = np.reshape(YCbCr, (4, 4, 4, 3))
        np.testing.assert_almost_equal(YCbCr_to_RGB(YCbCr), RGB)
Esempio n. 3
0
    def test_domain_range_scale_YCbCr_to_RGB(self):
        """
        Tests :func:`colour.models.rgb.prismatic.YCbCr_to_RGB` definition
        domain and range scale support.
        """

        YCbCr = np.array([0.52230157, 0.36699593, 0.62183309])
        RGB = YCbCr_to_RGB(YCbCr)

        d_r = (('reference', 1), (1, 1), (100, 100))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(
                    YCbCr_to_RGB(YCbCr * factor), RGB * factor, decimal=7)
Esempio n. 4
0
    def test_nan_YCbCr_to_RGB(self):
        """
        Tests :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` 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:
            YCbCr = np.array(case)
            YCbCr_to_RGB(YCbCr)