def test_n_dimensional_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition n-dimensional arrays support. """ f_Y_Y_n = 0.495929964178047 Y = 12.197225350000002 np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.tile(f_Y_Y_n, 6) Y = np.tile(Y, 6) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3)) Y = np.reshape(Y, (2, 3)) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7)
def test_nan_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition nan support. """ intermediate_luminance_function_CIE1976( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
def test_nan_intermediate_luminance_function_CIE1976(self): """ Test :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition nan support. """ intermediate_luminance_function_CIE1976( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition domain and range scale support. """ Y = intermediate_luminance_function_CIE1976(41.527875844653451, 100) for scale in ('reference', 1, 100): with domain_range_scale(scale): np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976( 41.527875844653451, 100), Y, decimal=7)
def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition domain and range scale support. """ Y = intermediate_luminance_function_CIE1976(41.527875844653451, 100) for scale in ('reference', 1, 100): with domain_range_scale(scale): np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976( 41.527875844653451, 100), Y, decimal=7)
def test_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition. """ self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.495929964178047), 12.197225350000002, places=7) self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.613072093530391), 23.042767810000004, places=7) self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.394876333449113), 6.157200790000001, places=7)
def test_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition. """ self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.495929964178047), 12.197225350000002, places=7) self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.613072093530391), 23.042767810000004, places=7) self.assertAlmostEqual( intermediate_luminance_function_CIE1976(0.394876333449113), 6.157200790000001, places=7)
def test_n_dimensional_intermediate_luminance_function_CIE1976(self): """ Tests :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition n-dimensional arrays support. """ f_Y_Y_n = 0.495929964178047 Y = intermediate_luminance_function_CIE1976(f_Y_Y_n) f_Y_Y_n = np.tile(f_Y_Y_n, 6) Y = np.tile(Y, 6) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3)) Y = np.reshape(Y, (2, 3)) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7) f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3, 1)) Y = np.reshape(Y, (2, 3, 1)) np.testing.assert_almost_equal( intermediate_luminance_function_CIE1976(f_Y_Y_n), Y, decimal=7)
def Lab_to_XYZ( Lab, illuminant=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']): """ Converts from *CIE L\\*a\\*b\\** colourspace to *CIE XYZ* tristimulus values. Parameters ---------- Lab : array_like *CIE L\\*a\\*b\\** colourspace array. illuminant : array_like, optional Reference *illuminant* *CIE xy* chromaticity coordinates or *CIE xyY* colourspace array. Returns ------- ndarray *CIE XYZ* tristimulus values. Notes ----- +----------------+-----------------------+-----------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``Lab`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``a`` : [-100, 100] | ``a`` : [-1, 1] | | | | | | | ``b`` : [-100, 100] | ``b`` : [-1, 1] | +----------------+-----------------------+-----------------+ | ``illuminant`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ +----------------+-----------------------+-----------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``XYZ`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ References ---------- :cite:`CIETC1-482004m` Examples -------- >>> import numpy as np >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_XYZ(Lab) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) """ L, a, b = tsplit(to_domain_100(Lab)) X_n, Y_n, Z_n = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant))) f_Y_Y_n = (L + 16) / 116 f_X_X_n = a / 500 + f_Y_Y_n f_Z_Z_n = f_Y_Y_n - b / 200 X = intermediate_luminance_function_CIE1976(f_X_X_n, X_n) Y = intermediate_luminance_function_CIE1976(f_Y_Y_n, Y_n) Z = intermediate_luminance_function_CIE1976(f_Z_Z_n, Z_n) XYZ = tstack([X, Y, Z]) return from_range_1(XYZ)
def Lab_to_XYZ( Lab, illuminant=ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']): """ Converts from *CIE L\\*a\\*b\\** colourspace to *CIE XYZ* tristimulus values. Parameters ---------- Lab : array_like *CIE L\\*a\\*b\\** 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** | +================+=======================+=================+ | ``Lab`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``a`` : [-100, 100] | ``a`` : [-1, 1] | | | | | | | ``b`` : [-100, 100] | ``b`` : [-1, 1] | +----------------+-----------------------+-----------------+ | ``illuminant`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ +----------------+-----------------------+-----------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +================+=======================+=================+ | ``XYZ`` | [0, 1] | [0, 1] | +----------------+-----------------------+-----------------+ References ---------- :cite:`CIETC1-482004m` Examples -------- >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_XYZ(Lab) # doctest: +ELLIPSIS array([ 0.2065400..., 0.1219722..., 0.0513695...]) """ L, a, b = tsplit(to_domain_100(Lab)) X_n, Y_n, Z_n = tsplit(xyY_to_XYZ(xy_to_xyY(illuminant))) f_Y_Y_n = (L + 16) / 116 f_X_X_n = a / 500 + f_Y_Y_n f_Z_Z_n = f_Y_Y_n - b / 200 X = intermediate_luminance_function_CIE1976(f_X_X_n, X_n) Y = intermediate_luminance_function_CIE1976(f_Y_Y_n, Y_n) Z = intermediate_luminance_function_CIE1976(f_Z_Z_n, Z_n) XYZ = tstack([X, Y, Z]) return from_range_1(XYZ)