Ejemplo n.º 1
0
    def test_chromatically_adapted_primaries(self):
        """
        Tests :func:`colour.models.rgb.derivation.\
chromatically_adapted_primaries` definition.
        """

        np.testing.assert_almost_equal(chromatically_adapted_primaries(
            np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]),
            np.array([0.32168, 0.33767]), np.array([0.34570, 0.35850])),
                                       np.array([[0.73431182, 0.26694964],
                                                 [0.02211963, 0.98038009],
                                                 [-0.05880375, -0.12573056]]),
                                       decimal=7)

        np.testing.assert_almost_equal(chromatically_adapted_primaries(
            np.array([0.640, 0.330, 0.300, 0.600, 0.150, 0.060]),
            np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850])),
                                       np.array([[0.64922534, 0.33062196],
                                                 [0.32425276, 0.60237128],
                                                 [0.15236177, 0.06118676]]),
                                       decimal=7)

        np.testing.assert_almost_equal(chromatically_adapted_primaries(
            np.array([0.640, 0.330, 0.300, 0.600, 0.150, 0.060]),
            np.array([0.31270, 0.32900]), np.array([0.34570, 0.35850]),
            'Bradford'),
                                       np.array([[0.64844144, 0.33085331],
                                                 [0.32119518, 0.59784434],
                                                 [0.15589322, 0.06604921]]),
                                       decimal=7)
Ejemplo n.º 2
0
    def test_nan_chromatically_adapted_primaries(self):
        """
        Tests :func:`colour.models.rgb.derivation.\
chromatically_adapted_primaries` definition nan support.
        """

        cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]
        cases = set(permutations(cases * 3, r=2))
        for case in cases:
            P = np.array(np.vstack((case, case, case)))
            W = np.array(case)
            chromatically_adapted_primaries(P, W, W)
Ejemplo n.º 3
0
    def test_nan_chromatically_adapted_primaries(self):
        """
        Tests :func:`colour.models.rgb.derivation.\
chromatically_adapted_primaries` definition nan support.
        """

        cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]
        cases = set(permutations(cases * 3, r=2))
        for case in cases:
            P = np.array(np.vstack([case, case, case]))
            W = np.array(case)
            chromatically_adapted_primaries(P, W, W)
Ejemplo n.º 4
0
    def test_chromatically_adapted_primaries(self):
        """
        Tests :func:`colour.models.rgb.derivation.\
chromatically_adapted_primaries` definition.
        """

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.73470, 0.26530,
                          0.00000, 1.00000,
                          0.00010, -0.07700]),
                np.array([0.32168, 0.33767]),
                np.array([0.34570, 0.35850])),
            np.array([[0.73431182, 0.26694964],
                      [0.02211963, 0.98038009],
                      [-0.05880375, -0.12573056]]),
            decimal=7)

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.640, 0.330,
                          0.300, 0.600,
                          0.150, 0.060]),
                np.array([0.31270, 0.32900]),
                np.array([0.34570, 0.35850])),
            np.array([[0.64922534, 0.33062196],
                      [0.32425276, 0.60237128],
                      [0.15236177, 0.06118676]]),
            decimal=7)

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.640, 0.330,
                          0.300, 0.600,
                          0.150, 0.060]),
                np.array([0.31270, 0.32900]),
                np.array([0.34570, 0.35850]),
                'Bradford'),
            np.array([[0.64844144, 0.33085331],
                      [0.32119518, 0.59784434],
                      [0.15589322, 0.06604921]]),
            decimal=7)
Ejemplo n.º 5
0
    def test_chromatically_adapted_primaries(self):
        """
        Tests :func:`colour.models.rgb.derivation.\
chromatically_adapted_primaries` definition.
        """

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.73470, 0.26530,
                          0.00000, 1.00000,
                          0.00010, -0.07700]),
                np.array([0.32168, 0.33767]),
                np.array([0.34567, 0.35850])),
            np.array([[0.7343147, 0.2669459],
                      [0.022058, 0.9804409],
                      [-0.0587459, -0.1256946]]),
            decimal=7)

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.640, 0.330,
                          0.300, 0.600,
                          0.150, 0.060]),
                np.array([0.31271, 0.32902]),
                np.array([0.34567, 0.35850])),
            np.array([[0.6492148, 0.3306242],
                      [0.3242141, 0.6023877],
                      [0.152359, 0.0611854]]),
            decimal=7)

        np.testing.assert_almost_equal(
            chromatically_adapted_primaries(
                np.array([0.640, 0.330,
                          0.300, 0.600,
                          0.150, 0.060]),
                np.array([0.31271, 0.32902]),
                np.array([0.34567, 0.35850]),
                'Bradford'),
            np.array([[0.6484318, 0.3308549],
                      [0.3211603, 0.5978621],
                      [0.155886, 0.0660431]]),
            decimal=7)
Ejemplo n.º 6
0
    def test_chromatically_adapt(self):
        """
        Test :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
chromatically_adapt` method.
        """

        whitepoint_t = np.array([0.31270, 0.32900])
        colourspace = self._colourspace.chromatically_adapt(
            whitepoint_t, "D50", "Bradford")

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            np.array([
                [0.73485524, 0.26422533],
                [-0.00617091, 1.01131496],
                [0.01596756, -0.06423550],
            ]),
            decimal=7,
        )
        np.testing.assert_array_almost_equal(colourspace.whitepoint,
                                             whitepoint_t,
                                             decimal=7)

        self.assertEqual(colourspace.whitepoint_name, "D50")

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            chromatically_adapted_primaries(
                self._colourspace.primaries,
                self._colourspace.whitepoint,
                whitepoint_t,
                "Bradford",
            ),
            decimal=7,
        )

        np.testing.assert_array_almost_equal(
            colourspace.matrix_RGB_to_XYZ,
            normalised_primary_matrix(colourspace.primaries,
                                      colourspace.whitepoint),
            decimal=7,
        )

        np.testing.assert_array_almost_equal(
            colourspace.matrix_XYZ_to_RGB,
            np.linalg.inv(
                normalised_primary_matrix(colourspace.primaries,
                                          colourspace.whitepoint)),
            decimal=7,
        )
Ejemplo n.º 7
0
    def test_chromatically_adapt(self):
        """
        Tests :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\
chromatically_adapt` method.
        """

        whitepoint_t = np.array([0.31270, 0.32900])
        colourspace = self._colourspace.chromatically_adapt(
            whitepoint_t, 'D50', 'Bradford')

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            np.array([
                [0.73485524, 0.26422533],
                [-0.00617091, 1.01131496],
                [0.01596756, -0.06423550],
            ]),
            decimal=7)
        np.testing.assert_array_almost_equal(
            colourspace.whitepoint, whitepoint_t, decimal=7)

        self.assertEqual(colourspace.whitepoint_name, 'D50')

        np.testing.assert_array_almost_equal(
            colourspace.primaries,
            chromatically_adapted_primaries(self._colourspace.primaries,
                                            self._colourspace.whitepoint,
                                            whitepoint_t, 'Bradford'),
            decimal=7)

        np.testing.assert_array_almost_equal(
            colourspace.RGB_to_XYZ_matrix,
            normalised_primary_matrix(colourspace.primaries,
                                      colourspace.whitepoint),
            decimal=7)

        np.testing.assert_array_almost_equal(
            colourspace.XYZ_to_RGB_matrix,
            np.linalg.inv(
                normalised_primary_matrix(colourspace.primaries,
                                          colourspace.whitepoint)),
            decimal=7)