示例#1
0
    def test_n_dimensional_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition n-dimensional
        support.
        """

        Luv = np.array([41.52787529, 96.83626054, 17.75210149])
        illuminant = np.array([0.31270, 0.32900])
        XYZ = Luv_to_XYZ(Luv, illuminant)

        Luv = np.tile(Luv, (6, 1))
        XYZ = np.tile(XYZ, (6, 1))
        np.testing.assert_almost_equal(Luv_to_XYZ(Luv, illuminant),
                                       XYZ,
                                       decimal=7)

        illuminant = np.tile(illuminant, (6, 1))
        np.testing.assert_almost_equal(Luv_to_XYZ(Luv, illuminant),
                                       XYZ,
                                       decimal=7)

        Luv = np.reshape(Luv, (2, 3, 3))
        illuminant = np.reshape(illuminant, (2, 3, 2))
        XYZ = np.reshape(XYZ, (2, 3, 3))
        np.testing.assert_almost_equal(Luv_to_XYZ(Luv, illuminant),
                                       XYZ,
                                       decimal=7)
示例#2
0
    def test_n_dimensional_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition n-dimensions
        support.
        """

        Luv = np.array([37.98562910, -28.80219593, -1.35800706])
        illuminant = np.array([0.34570, 0.35850])
        XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
        np.testing.assert_almost_equal(
            Luv_to_XYZ(Luv, illuminant),
            XYZ,
            decimal=7)

        Luv = np.tile(Luv, (6, 1))
        XYZ = np.tile(XYZ, (6, 1))
        np.testing.assert_almost_equal(
            Luv_to_XYZ(Luv, illuminant),
            XYZ,
            decimal=7)

        illuminant = np.tile(illuminant, (6, 1))
        np.testing.assert_almost_equal(
            Luv_to_XYZ(Luv, illuminant),
            XYZ,
            decimal=7)

        Luv = np.reshape(Luv, (2, 3, 3))
        illuminant = np.reshape(illuminant, (2, 3, 2))
        XYZ = np.reshape(XYZ, (2, 3, 3))
        np.testing.assert_almost_equal(
            Luv_to_XYZ(Luv, illuminant),
            XYZ,
            decimal=7)
示例#3
0
    def test_domain_range_scale_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition
        domain and range scale support.
        """

        Luv = np.array([41.52787529, 96.83626054, 17.75210149])
        illuminant = np.array([0.31270, 0.32900])
        XYZ = Luv_to_XYZ(Luv, illuminant)

        d_r = (('reference', 1, 1), (1, 0.01, 1), (100, 1, 100))
        for scale, factor_a, factor_b in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(Luv_to_XYZ(
                    Luv * factor_a, illuminant),
                                               XYZ * factor_b,
                                               decimal=7)
示例#4
0
    def test_nan_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` 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:
            Luv = np.array(case)
            illuminant = np.array(case[0:2])
            Luv_to_XYZ(Luv, illuminant)
示例#5
0
    def test_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, -11.27488915, -29.36041662])),
                                       np.array([0.96907232, 1., 1.12179215]),
                                       decimal=7)

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, 331.44911128, 72.55258319])),
                                       np.array([1.92001986, 1., -0.1241347]),
                                       decimal=7)

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, -36.17788915, -111.00091702])),
                                       np.array([1.0131677, 1., 2.11217686]),
                                       decimal=7)

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, -97.02442861, -158.08546907]), (0.44757, 0.40745)),
                                       np.array([1.0131677, 1., 2.11217686]),
                                       decimal=7)

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, -37.95520989, -92.29247371]), (1 / 3, 1 / 3)),
                                       np.array([1.0131677, 1., 2.11217686]),
                                       decimal=7)

        np.testing.assert_almost_equal(Luv_to_XYZ(
            np.array([100, -21.44928374, -85.33481874]), (0.31271, 0.32902)),
                                       np.array([1.0131677, 1., 2.11217686]),
                                       decimal=7)
示例#6
0
    def test_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -28.80219593, -1.35800706])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([65.70971880, 87.19996716, 27.01112399])),
            np.array([0.47097710, 0.34950000, 0.11301649]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([50.86223896, 60.51033649, 13.13737985])),
            np.array([0.25506814, 0.19150000, 0.08849752]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -51.90523525, -19.24118281]),
                       np.array([0.44757, 0.40745])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -23.19781615, 8.39962073]),
                       np.array([0.31270, 0.32900])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -34.23840374, -7.09461715]),
                       np.array([0.37208, 0.37529])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -34.23840374, -7.09461715]),
                       np.array([0.37208, 0.37529, 0.10080])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)
示例#7
0
    def test_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -28.79229446, -1.35581950])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([65.70971880, 87.21709531, 27.01490816])),
            np.array([0.47097710, 0.34950000, 0.11301649]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([50.86223896, 60.52359443, 13.14030896])),
            np.array([0.25506814, 0.19150000, 0.08849752]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -51.90523525, -19.24118281]),
                       np.array([0.44757, 0.40745])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -23.19754103, 8.39360940]),
                       np.array([0.31271, 0.32902])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -34.23840374, -7.09461715]),
                       np.array([0.37208, 0.37529])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([37.98562910, -34.23840374, -7.09461715]),
                       np.array([0.37208, 0.37529, 0.10080])),
            np.array([0.07049534, 0.10080000, 0.09558313]),
            decimal=7)
示例#8
0
    def test_Luv_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_luv.Luv_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([41.52787529, 96.83626054, 17.75210149])),
            np.array([0.20654008, 0.12197225, 0.05136952]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([55.11636304, -37.59308176, 44.13768458])),
            np.array([0.14222010, 0.23042768, 0.10495772]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([29.80565520, -10.96316802, -65.06751860])),
            np.array([0.07818780, 0.06157201, 0.28099326]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([41.52787529, 65.45180940, -12.46626977]),
                       np.array([0.44757, 0.40745])),
            np.array([0.20654008, 0.12197225, 0.05136952]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([41.52787529, 90.70925962, 7.08455273]),
                       np.array([0.34570, 0.35850])),
            np.array([0.20654008, 0.12197225, 0.05136952]),
            decimal=7)

        np.testing.assert_almost_equal(
            Luv_to_XYZ(np.array([41.52787529, 90.70925962, 7.08455273]),
                       np.array([0.34570, 0.35850, 1.00000])),
            np.array([0.20654008, 0.12197225, 0.05136952]),
            decimal=7)