Coverage for colour/difference/din99.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-15 19:01 +1300

1""" 

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

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

4 

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

6 

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

8 

9References 

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 

17from __future__ import annotations 

18 

19from colour.algebra import euclidean_distance 

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

21from colour.models import Lab_to_DIN99 

22from 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 

36def 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 )