Пример #1
0
    def test_n_dimensional_Hunter_Lab_to_XYZ(self):
        """
        Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition
        n-dimensional support.
        """

        h_i = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"]
        D65 = h_i["D65"]

        Lab = np.array([34.92452577, 47.06189858, 14.38615107])
        XYZ_n = D65.XYZ_n
        K_ab = D65.K_ab
        XYZ = Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab)

        Lab = np.tile(Lab, (6, 1))
        XYZ = np.tile(XYZ, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        K_ab = np.tile(K_ab, (6, 1))
        XYZ_n = np.tile(XYZ_n, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        Lab = np.reshape(Lab, (2, 3, 3))
        XYZ_n = np.reshape(XYZ_n, (2, 3, 3))
        K_ab = np.reshape(K_ab, (2, 3, 2))
        XYZ = np.reshape(XYZ, (2, 3, 3))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)
Пример #2
0
    def test_domain_range_scale_Hunter_Lab_to_XYZ(self):
        """
        Tests :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition
        domain and range scale support.
        """

        h_i = HUNTERLAB_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
        D65 = h_i['D65']

        Lab = np.array([34.92452577, 47.06189858, 14.38615107])
        XYZ_n = D65.XYZ_n
        K_ab = D65.K_ab
        XYZ = Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab)

        d_r = (('reference', 1), (1, 0.01), (100, 1))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(
                    Lab * factor, XYZ_n * factor, K_ab),
                                               XYZ * factor,
                                               decimal=7)
Пример #3
0
    def test_nan_Hunter_Lab_to_XYZ(self):
        """
        Tests :func:`colour.models.hunter_lab.Hunter_Lab_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:
            Lab = np.array(case)
            XYZ_n = np.array(case[0:3])
            K_ab = np.array(case[0:2])
            Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab)
Пример #4
0
    def test_n_dimensional_Hunter_Lab_to_XYZ(self):
        """
        Tests :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition
        n-dimensions support.
        """

        h_i = HUNTERLAB_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
        D65 = h_i['D65']

        Lab = np.array([34.92452577, 47.06189858, 14.38615107])
        XYZ_n = D65.XYZ_n
        K_ab = D65.K_ab
        XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) * 100
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        Lab = np.tile(Lab, (6, 1))
        XYZ = np.tile(XYZ, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        K_ab = np.tile(K_ab, (6, 1))
        XYZ_n = np.tile(XYZ_n, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        Lab = np.reshape(Lab, (2, 3, 3))
        XYZ_n = np.reshape(XYZ_n, (2, 3, 3))
        K_ab = np.reshape(K_ab, (2, 3, 2))
        XYZ = np.reshape(XYZ, (2, 3, 3))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)
Пример #5
0
    def test_n_dimensional_Hunter_Lab_to_XYZ(self):
        """
        Tests :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition
        n-dimensions support.
        """

        h_i = HUNTERLAB_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
        D50 = h_i['D50']

        Lab = np.array([31.74901573, -15.11462629, -2.78660758])
        XYZ_n = D50.XYZ_n
        K_ab = D50.K_ab
        XYZ = np.array([0.07049534, 0.10080000, 0.09558313]) * 100
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        Lab = np.tile(Lab, (6, 1))
        XYZ = np.tile(XYZ, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        K_ab = np.tile(K_ab, (6, 1))
        XYZ_n = np.tile(XYZ_n, (6, 1))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)

        Lab = np.reshape(Lab, (2, 3, 3))
        XYZ_n = np.reshape(XYZ_n, (2, 3, 3))
        K_ab = np.reshape(K_ab, (2, 3, 2))
        XYZ = np.reshape(XYZ, (2, 3, 3))
        np.testing.assert_almost_equal(Hunter_Lab_to_XYZ(Lab, XYZ_n, K_ab),
                                       XYZ,
                                       decimal=7)
Пример #6
0
    def test_Hunter_Lab_to_XYZ(self):
        """Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition."""

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(np.array([34.92452577, 47.06189858,
                                        14.38615107])),
            np.array([20.65400800, 12.19722500, 5.13695200]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([48.00288325, -28.98551622, 18.75564181])),
            np.array([14.22201000, 23.04276800, 10.49577200]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([24.81370791, 14.38300039, -53.25539126])),
            np.array([7.81878000, 6.15720100, 28.09932601]),
            decimal=7,
        )

        h_i = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"]
        A = h_i["A"]
        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([34.92452577, 35.04243086, -2.47688619]),
                A.XYZ_n,
                A.K_ab,
            ),
            np.array([20.65400800, 12.19722500, 5.13695200]),
            decimal=7,
        )

        D65 = h_i["D65"]
        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([34.92452577, 47.06189858, 14.38615107]),
                D65.XYZ_n,
                D65.K_ab,
            ),
            np.array([20.65400800, 12.19722500, 5.13695200]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([34.92452577, 47.05669614, 14.38385238]),
                D65.XYZ_n,
                K_ab=None,
            ),
            np.array([20.65400800, 12.19722500, 5.13695200]),
            decimal=7,
        )
Пример #7
0
    def test_Hunter_Lab_to_XYZ(self):
        """
        Tests :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([31.74901573, -15.11462629, -2.78660758])),
            np.array([7.04953400, 10.08000000, 9.55831300]),
            decimal=7)

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(np.array([59.11852502, 40.84479160,
                                        21.01328651])),
            np.array([47.09771001, 34.95000001, 11.30164900]),
            decimal=7)

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(np.array([43.76071297, 29.00314048,
                                        11.24749156])),
            np.array([25.50681403, 19.15000002, 8.84975199]),
            decimal=7)

        h_i = HUNTERLAB_ILLUMINANTS['CIE 1931 2 Degree Standard Observer']
        A = h_i['A']
        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(
                np.array([31.74901573, -21.35794415, -20.32778374]), A.XYZ_n,
                A.K_ab),
            np.array([7.04953400, 10.08000000, 9.55831300]),
            decimal=7)

        D65 = h_i['D65']
        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(np.array([31.7490157, -14.4410859, 2.7439626]),
                              D65.XYZ_n, D65.K_ab),
            np.array([7.04953400, 10.08000000, 9.55831300]),
            decimal=7)

        np.testing.assert_almost_equal(
            Hunter_Lab_to_XYZ(np.array([31.74901573, -14.43948953,
                                        2.74352417]),
                              D65.XYZ_n,
                              K_ab=None),
            np.array([7.04953400, 10.08000000, 9.55831300]),
            decimal=7)