def test_domain_range_scale_Jab_to_JCh(self): """ Tests :func:`colour.models.common.Jab_to_JCh` definition domain and range scale support. """ Lab = np.array([41.52787529, 52.63858304, 26.92317922]) LCHab = Jab_to_JCh(Lab) d_r = (('reference', 1, 1), (1, 0.01, np.array([0.01, 0.01, 1 / 360])), (100, 1, np.array([1, 1, 1 / 3.6]))) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): np.testing.assert_almost_equal(Jab_to_JCh(Lab * factor_a), LCHab * factor_b, decimal=7)
def test_n_dimensional_Jab_to_JCh(self): """ Tests :func:`colour.models.common.Jab_to_JCh` definition n-dimensional arrays support. """ Lab = np.array([41.52787529, 52.63858304, 26.92317922]) LCHab = Jab_to_JCh(Lab) Lab = np.tile(Lab, (6, 1)) LCHab = np.tile(LCHab, (6, 1)) np.testing.assert_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7) Lab = np.reshape(Lab, (2, 3, 3)) LCHab = np.reshape(LCHab, (2, 3, 3)) np.testing.assert_almost_equal(Jab_to_JCh(Lab), LCHab, decimal=7)
def test_nan_Jab_to_JCh(self): """Test :func:`colour.models.common.Jab_to_JCh` 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) Jab_to_JCh(Lab)
def test_Jab_to_JCh(self): """ Tests :func:`colour.models.common.Jab_to_JCh` definition. """ np.testing.assert_almost_equal( Jab_to_JCh(np.array([41.52787529, 52.63858304, 26.92317922])), np.array([41.52787529, 59.12425901, 27.08848784]), decimal=7) np.testing.assert_almost_equal( Jab_to_JCh(np.array([55.11636304, -41.08791787, 30.91825778])), np.array([55.11636304, 51.42135412, 143.03889556]), decimal=7) np.testing.assert_almost_equal( Jab_to_JCh(np.array([29.80565520, 20.01830466, -48.34913874])), np.array([29.80565520, 52.32945383, 292.49133666]), decimal=7)
def Lab_to_LCHab(Lab): """ Converts from *CIE L\\*a\\*b\\** colourspace to *CIE L\\*C\\*Hab* colourspace. Parameters ---------- Lab : array_like *CIE L\\*a\\*b\\** colourspace array. Returns ------- ndarray *CIE L\\*C\\*Hab* colourspace array. 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] | +------------+-----------------------+-----------------+ +------------+-----------------------+------------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+==================+ | ``LCHab`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``C`` : [0, 100] | ``C`` : [0, 1] | | | | | | | ``Hab`` : [0, 360] | ``Hab`` : [0, 1] | +------------+-----------------------+------------------+ References ---------- :cite:`CIETC1-482004m` Examples -------- >>> import numpy as np >>> Lab = np.array([41.52787529, 52.63858304, 26.92317922]) >>> Lab_to_LCHab(Lab) # doctest: +ELLIPSIS array([ 41.5278752..., 59.1242590..., 27.0884878...]) """ return Jab_to_JCh(Lab)
def Luv_to_LCHuv(Luv): """ Converts from *CIE L\\*u\\*v\\** colourspace to *CIE L\\*C\\*Huv* colourspace. Parameters ---------- Luv : array_like *CIE L\\*u\\*v\\** colourspace array. Returns ------- ndarray *CIE L\\*C\\*Huv* colourspace array. 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] | +------------+-----------------------+-----------------+ +------------+-----------------------+------------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+==================+ | ``LCHuv`` | ``L`` : [0, 100] | ``L`` : [0, 1] | | | | | | | ``C`` : [0, 100] | ``C`` : [0, 1] | | | | | | | ``Huv`` : [0, 360] | ``Huv`` : [0, 1] | +------------+-----------------------+------------------+ References ---------- :cite:`CIETC1-482004m` Examples -------- >>> import numpy as np >>> Luv = np.array([41.52787529, 96.83626054, 17.75210149]) >>> Luv_to_LCHuv(Luv) # doctest: +ELLIPSIS array([ 41.5278752..., 98.4499795..., 10.3881634...]) """ return Jab_to_JCh(Luv)