Coverage for difference/din99.py: 24%

1"""

2:math:`\\Delta E_{99}` DIN99 - Colour Difference Formula

3========================================================

4

5 Define the :math:`\\Delta E_{99}` *DIN99* colour difference formula.

6

7- :func:`colour.difference.delta_E_DIN99`

8

9 References

10----------

11- :cite:`ASTMInternational2007` : ASTM International. (2007). ASTM D2244-07 -

12 Standard Practice for Calculation of Color Tolerances and Color Differences

13 from Instrumentally Measured Color Coordinates: Vol. i (pp. 1-10).

14 doi:10.1520/D2244-16

15"""

16

17 from __future__ import annotations

18

19 from colour.algebra import euclidean_distance

20 from colour.hints import Domain100, NDArrayFloat # noqa: TC001

21 from colour.models import Lab_to_DIN99

22 from colour.utilities import get_domain_range_scale

23

24 __author__ = "Colour Developers"

25 __copyright__ = "Copyright 2013 Colour Developers"

26 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

27 __maintainer__ = "Colour Developers"

28 __email__ = "colour-developers@colour-science.org"

29 __status__ = "Production"

30

31 __all__ = [

32 "delta_E_DIN99",

33]

34

35

36 def delta_E_DIN99(

37 Lab_1: Domain100,

38 Lab_2: Domain100,

39 textiles: bool = False,

40) -> NDArrayFloat:

41 """

42 Compute the colour difference :math:`\\Delta E_{DIN99}` between two

43 specified *CIE L\\*a\\*b\\** colourspace arrays using the *DIN99* formula.

44

45 Parameters

46 ----------

47 Lab_1

48 *CIE L\\*a\\*b\\** colourspace array 1.

49 Lab_2

50 *CIE L\\*a\\*b\\** colourspace array 2.

51 textiles

52 Textiles application specific parametric factors,

53 :math:`k_E=2,\\ k_{CH}=0.5` weights are used instead of

54 :math:`k_E=1,\\ k_{CH}=1`.

55

56 Returns

57 -------

58 :class:`numpy.ndarray`

59 Colour difference :math:`\\Delta E_{DIN99}`.

60

61 Notes

62 -----

63 +------------+-----------------------+-------------------+

64 | **Domain** | **Scale - Reference** | **Scale - 1** |

65 +============+=======================+===================+

66 | ``Lab_1`` | 100 | 1 |

67 +------------+-----------------------+-------------------+

68 | ``Lab_2`` | 100 | 1 |

69 +------------+-----------------------+-------------------+

70

71 References

72 ----------

73 :cite:`ASTMInternational2007`

74

75 Examples

76 --------

77 >>> import numpy as np

78 >>> Lab_1 = np.array([60.2574, -34.0099, 36.2677])

79 >>> Lab_2 = np.array([60.4626, -34.1751, 39.4387])

80 >>> delta_E_DIN99(Lab_1, Lab_2) # doctest: +ELLIPSIS

81 1.1772166...

82 """

83

84 k_E = 2 if textiles else 1

85 k_CH = 0.5 if textiles else 1

86

87 factor = 100 if get_domain_range_scale() == "1" else 1

88

89 return euclidean_distance(

90 Lab_to_DIN99(Lab_1, k_E, k_CH) * factor,

91 Lab_to_DIN99(Lab_2, k_E, k_CH) * factor,

92 )