Coverage for quality/__init__.py: 13%

1 from __future__ import annotations

2

3 import typing

4

5 if typing.TYPE_CHECKING:

6 from colour.colorimetry import SpectralDistribution

7 from colour.hints import Literal

8

9 from colour.utilities import CanonicalMapping, validate_method

10

11 from . import datasets

12 from .cfi2017 import (

13 ColourRendering_Specification_CIE2017,

14 colour_fidelity_index_CIE2017,

15)

16 from .cqs import (

17 COLOUR_QUALITY_SCALE_METHODS,

18 ColourRendering_Specification_CQS,

19 colour_quality_scale,

20)

21 from .cri import (

22 COLOUR_RENDERING_INDEX_METHODS,

23 ColourRendering_Specification_CRI,

24 colour_rendering_index,

25)

26 from .datasets import * # noqa: F403

27 from .ssi import spectral_similarity_index

28 from .tm3018 import (

29 ColourQuality_Specification_ANSIIESTM3018,

30 colour_fidelity_index_ANSIIESTM3018,

31)

32

33 __all__ = datasets.__all__

34 __all__ += [

35 "ColourRendering_Specification_CIE2017",

36 "colour_fidelity_index_CIE2017",

37]

38 __all__ += [

39 "COLOUR_QUALITY_SCALE_METHODS",

40 "ColourRendering_Specification_CQS",

41 "colour_quality_scale",

42]

43 __all__ += [

44 "COLOUR_RENDERING_INDEX_METHODS",

45 "ColourRendering_Specification_CRI",

46 "colour_rendering_index",

47]

48 __all__ += [

49 "spectral_similarity_index",

50]

51 __all__ += [

52 "ColourQuality_Specification_ANSIIESTM3018",

53 "colour_fidelity_index_ANSIIESTM3018",

54]

55

56 COLOUR_FIDELITY_INDEX_METHODS = CanonicalMapping(

57 {

58 "CIE 2017": colour_fidelity_index_CIE2017,

59 "ANSI/IES TM-30-18": colour_fidelity_index_ANSIIESTM3018,

60 }

61)

62 COLOUR_FIDELITY_INDEX_METHODS.__doc__ = """

63 Supported *Colour Fidelity Index* (CFI) computation methods.

64

65 References

66----------

67:cite:`CIETC1-902017`, :cite:`ANSI2018`

68"""

69

70

71 def colour_fidelity_index(

72 sd_test: SpectralDistribution,

73 additional_data: bool = False,

74 method: Literal["CIE 2017", "ANSI/IES TM-30-18"] | str = "CIE 2017",

75) -> (

76 float

77 | ColourRendering_Specification_CIE2017

78 | ColourQuality_Specification_ANSIIESTM3018

79):

80 """

81 Compute the *Colour Fidelity Index* (CFI) :math:`R_f` of the specified

82 spectral distribution using the specified method.

83

84 Parameters

85 ----------

86 sd_test

87 Test spectral distribution.

88 additional_data

89 Whether to output additional data.

90 method

91 Computation method.

92

93 Returns

94 -------

95 :class:`float` or \

96:class:`colour.quality.ColourRendering_Specification_CIE2017` or \

97:class:`colour.quality.ColourQuality_Specification_ANSIIESTM3018`

98 *Colour Fidelity Index* (CFI) :math:`R_f`.

99

100 References

101 ----------

102 :cite:`CIETC1-902017`, :cite:`ANSI2018`

103

104 Examples

105 --------

106 >>> from colour.colorimetry import SDS_ILLUMINANTS

107 >>> sd = SDS_ILLUMINANTS["FL2"]

108 >>> colour_fidelity_index(sd) # doctest: +ELLIPSIS

109 70.1208244...

110 """

111

112 method = validate_method(method, tuple(COLOUR_FIDELITY_INDEX_METHODS))

113

114 function = COLOUR_FIDELITY_INDEX_METHODS[method]

115

116 return function(sd_test, additional_data)

117

118

119 __all__ += [

120 "COLOUR_FIDELITY_INDEX_METHODS",

121 "colour_fidelity_index",

122]