def test_nan_luminance_CIE1976(self): """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition nan support. """ luminance_CIE1976(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
def test_nan_luminance_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.luminance_CIE1976` definition nan support. """ luminance_CIE1976(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
def test_domain_range_scale_luminance_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.luminance_CIE1976` definition domain and range scale support. """ Y = luminance_CIE1976(41.527875844653451, 100) 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( luminance_CIE1976(41.527875844653451 * factor, 100), Y * factor, decimal=7)
def test_domain_range_scale_luminance_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.luminance_CIE1976` definition domain and range scale support. """ Y = luminance_CIE1976(41.527875844653451, 100) 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(luminance_CIE1976( 41.527875844653451 * factor, 100), Y * factor, decimal=7)
def test_n_dimensional_luminance_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.luminance_CIE1976` definition n-dimensional arrays support. """ L_star = 41.527875844653451 Y = luminance_CIE1976(L_star) L_star = np.tile(L_star, 6) Y = np.tile(Y, 6) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3)) Y = np.reshape(Y, (2, 3)) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7)
def test_n_dimensional_luminance_CIE1976(self): """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition n-dimensional arrays support. """ L_star = 41.527875844653451 Y = luminance_CIE1976(L_star) L_star = np.tile(L_star, 6) Y = np.tile(Y, 6) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3)) Y = np.reshape(Y, (2, 3)) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7) L_star = np.reshape(L_star, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) np.testing.assert_almost_equal(luminance_CIE1976(L_star), Y, decimal=7)
def test_luminance_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.luminance_CIE1976` definition. """ self.assertAlmostEqual( luminance_CIE1976(41.527875844653451), 12.197225350000002, places=7) self.assertAlmostEqual( luminance_CIE1976(55.116362849525402), 23.042767810000004, places=7) self.assertAlmostEqual( luminance_CIE1976(29.805654680097106), 6.157200790000001, places=7) self.assertAlmostEqual( luminance_CIE1976(56.480581732417676, 50), 12.197225349999998, places=7) self.assertAlmostEqual( luminance_CIE1976(47.317620274162735, 75), 12.197225350000002, places=7) self.assertAlmostEqual( luminance_CIE1976(42.519930728120940, 95), 12.197225350000005, places=7)
def test_luminance_CIE1976(self): """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition. """ self.assertAlmostEqual(luminance_CIE1976(41.527875844653451), 12.197225350000002, places=7) self.assertAlmostEqual(luminance_CIE1976(55.116362849525402), 23.042767810000004, places=7) self.assertAlmostEqual(luminance_CIE1976(29.805654680097106), 6.157200790000001, places=7) self.assertAlmostEqual( luminance_CIE1976(56.480581732417676, 50), 12.197225349999998, places=7, ) self.assertAlmostEqual( luminance_CIE1976(47.317620274162735, 75), 12.197225350000002, places=7, ) self.assertAlmostEqual( luminance_CIE1976(42.519930728120940, 95), 12.197225350000005, places=7, )
def Luv_to_XYZ( Luv, illuminant=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']): """ Converts from *CIE L\\*u\\*v\\** colourspace to *CIE XYZ* tristimulus values. Parameters ---------- Luv : array_like *CIE L\\*u\\*v\\** colourspace array. illuminant : array_like, optional Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY* colourspace array. Returns ------- ndarray *CIE XYZ* tristimulus values. Notes ----- +----------------+-----------------------+-----------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``Luv`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``u`` : [-100, 100] | ``u`` : [-1, 1] | | | | | | | ``v`` : [-100, 100] | ``v`` : [-1, 1] | +----------------+-----------------------+-----------------+ | ``illuminant`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ +----------------+-----------------------+-----------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``XYZ`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ References ---------- :cite:`CIETC1-482004m`, :cite:`Wikipedia2007b` Examples -------- >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) """ L, u, v = tsplit(to_domain_100(Luv)) X_r, Y_r, Z_r = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant))) with domain_range_scale('100'): Y = luminance_CIE1976(L, Y_r) a = 1 / 3 * ((52 * L / (u + 13 * L * (4 * X_r / (X_r + 15 * Y_r + 3 * Z_r)))) - 1) b = -5 * Y c = -1 / 3.0 d = Y * (39 * L / (v + 13 * L * (9 * Y_r / (X_r + 15 * Y_r + 3 * Z_r))) - 5) X = (d - b) / (a - c) Z = X * a + b XYZ = tstack([X, Y, Z]) return from_range_1(XYZ)
def Luv_to_XYZ( Luv, illuminant=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']): """ Converts from *CIE L\\*u\\*v\\** colourspace to *CIE XYZ* tristimulus values. Parameters ---------- Luv : array_like *CIE L\\*u\\*v\\** colourspace array. illuminant : array_like, optional Reference *illuminant* *xy* chromaticity coordinates or *CIE xyY* colourspace array. Returns ------- ndarray *CIE XYZ* tristimulus values. Notes ----- +----------------+-----------------------+-----------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``Luv`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``u`` : [-100, 100] | ``u`` : [-1, 1] | | | | | | | ``v`` : [-100, 100] | ``v`` : [-1, 1] | +----------------+-----------------------+-----------------+ | ``illuminant`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ +----------------+-----------------------+-----------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``XYZ`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ References ---------- :cite:`CIETC1-482004m`, :cite:`Wikipedia2007b` Examples -------- >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_XYZ(Luv) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) """ L, u, v = tsplit(to_domain_100(Luv)) X_r, Y_r, Z_r = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant))) with domain_range_scale('100'): Y = luminance_CIE1976(L, Y_r) a = 1 / 3 * ( (52 * L / (u + 13 * L * (4 * X_r / (X_r + 15 * Y_r + 3 * Z_r)))) - 1) b = -5 * Y c = -1 / 3.0 d = Y * (39 * L / (v + 13 * L * (9 * Y_r / (X_r + 15 * Y_r + 3 * Z_r))) - 5) X = (d - b) / (a - c) Z = X * a + b XYZ = tstack([X, Y, Z]) return from_range_1(XYZ)