Coverage for volume/pointer_gamut.py: 12%

16 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-16 22:49 +1300

1""" 

2Pointer's Gamut Volume Computations 

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

4 

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

6""" 

7 

8from __future__ import annotations 

9 

10import typing 

11 

12from colour.constants import EPSILON 

13 

14if typing.TYPE_CHECKING: 

15 from colour.hints import ArrayLike, NDArrayFloat 

16 

17from colour.models import LCHab_to_Lab # pyright: ignore 

18from colour.models import ( 

19 CCS_ILLUMINANT_POINTER_GAMUT, 

20 DATA_POINTER_GAMUT_VOLUME, 

21 Lab_to_XYZ, 

22) 

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

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