Coverage for volume/pointer_gamut.py: 12%

1"""

2 Pointer's Gamut Volume Computations

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

4

5 Define objects and computations for *Pointer's Gamut* volume analysis.

6"""

7

8 from __future__ import annotations

9

10 import typing

11

12 from colour.constants import EPSILON

13

14 if typing.TYPE_CHECKING:

15 from colour.hints import ArrayLike, NDArrayFloat

16

17 from colour.models import LCHab_to_Lab # pyright: ignore

18 from colour.models import (

19 CCS_ILLUMINANT_POINTER_GAMUT,

20 DATA_POINTER_GAMUT_VOLUME,

21 Lab_to_XYZ,

22)

23 from colour.volume import is_within_mesh_volume

24

25 __author__ = "Colour Developers"

26 __copyright__ = "Copyright 2013 Colour Developers"

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

28 __maintainer__ = "Colour Developers"

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

30 __status__ = "Production"

31

32 __all__ = [

33 "is_within_pointer_gamut",

34]

35

36

37 def is_within_pointer_gamut(

38 XYZ: ArrayLike, tolerance: float = 100 * EPSILON

39) -> NDArrayFloat:

40 """

41 Determine whether the specified *CIE XYZ* tristimulus values are within

42 Pointer's Gamut volume.

43

44 Parameters

45 ----------

46 XYZ

47 *CIE XYZ* tristimulus values.

48 tolerance

49 Tolerance allowed in the inside-triangle check.

50

51 Returns

52 -------

53 :class:`numpy.ndarray`

54 Boolean array indicating whether specified *CIE XYZ* tristimulus

55 values are within Pointer's Gamut volume.

56

57 Notes

58 -----

59 +------------+-----------------------+---------------+

60 | **Domain** | **Scale - Reference** | **Scale - 1** |

61 +============+=======================+===============+

62 | ``XYZ`` | 1 | 1 |

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

64

65 Examples

66 --------

67 >>> import numpy as np

68 >>> is_within_pointer_gamut(np.array([0.3205, 0.4131, 0.5100]))

69 array(True, dtype=bool)

70 >>> a = np.array([[0.3205, 0.4131, 0.5100], [0.0005, 0.0031, 0.0010]])

71 >>> is_within_pointer_gamut(a)

72 array([ True, False], dtype=bool)

73 """

74

75 XYZ_p = Lab_to_XYZ(

76 LCHab_to_Lab(DATA_POINTER_GAMUT_VOLUME), CCS_ILLUMINANT_POINTER_GAMUT

77 )

78

79 return is_within_mesh_volume(XYZ, XYZ_p, tolerance)