19
19
from colour import (Lab_to_XYZ , LCHab_to_Lab , LOG_DECODING_CURVES ,
20
20
POINTER_GAMUT_DATA , POINTER_GAMUT_ILLUMINANT ,
21
21
OETFS_REVERSE , RGB_COLOURSPACES , RGB_to_RGB , RGB_to_XYZ ,
22
- XYZ_to_RGB , XYZ_to_JzAzBz , XYZ_to_OSA_UCS , read_image )
22
+ XYZ_to_RGB , XYZ_to_JzAzBz , XYZ_to_OSA_UCS ,
23
+ is_within_pointer_gamut , read_image )
23
24
from colour .models import (XYZ_to_colourspace_model , function_gamma ,
24
25
function_linear )
25
26
from colour .plotting import filter_cmfs , filter_RGB_colourspaces
38
39
'COLOURSPACE_MODELS' , 'COLOURSPACE_MODELS_LABELS' , 'DECODING_CCTFS' ,
39
40
'PRIMARY_COLOURSPACE' , 'SECONDARY_COLOURSPACE' , 'IMAGE_COLOURSPACE' ,
40
41
'IMAGE_DECODING_CCTF' , 'COLOURSPACE_MODEL' , 'IMAGE_CACHE' , 'load_image' ,
41
- 'XYZ_to_colourspace_model_normalised' ,'colourspace_model_axis_reorder' , 'colourspace_model_faces_reorder ' ,
42
- 'decoding_cctfs ' , 'colourspace_models ' , 'RGB_colourspaces ' ,
43
- 'buffer_geometry ' , 'create_plane ' , 'create_box ' , 'image_data ' ,
44
- 'RGB_colourspace_volume_visual' , 'spectral_locus_visual' ,
42
+ 'XYZ_to_colourspace_model_normalised' , 'colourspace_model_axis_reorder ' ,
43
+ 'colourspace_model_faces_reorder ' , 'decoding_cctfs ' , 'colourspace_models ' ,
44
+ 'RGB_colourspaces ' , 'buffer_geometry ' , 'create_plane ' , 'create_box ' ,
45
+ 'image_data' , ' RGB_colourspace_volume_visual' , 'spectral_locus_visual' ,
45
46
'RGB_image_scatter_visual' , 'pointer_gamut_visual'
46
47
]
47
48
@@ -647,6 +648,7 @@ def image_data(path,
647
648
image_decoding_cctf = IMAGE_DECODING_CCTF ,
648
649
out_of_primary_colourspace_gamut = False ,
649
650
out_of_secondary_colourspace_gamut = False ,
651
+ out_of_pointer_gamut = False ,
650
652
saturate = False ):
651
653
"""
652
654
Returns given image RGB data or its out of gamut values formatted as
@@ -673,7 +675,9 @@ def image_data(path,
673
675
values.
674
676
out_of_secondary_colourspace_gamut : bool, optional
675
677
Whether to only generate the out of secondary RGB colourspace gamut
676
- value.
678
+ values.
679
+ out_of_pointer_gamut : bool, optional
680
+ Whether to only generate the out of *Pointer's Gamut* values.
677
681
saturate : bool, optional
678
682
Whether to clip the image in domain [0, 1].
679
683
@@ -690,6 +694,9 @@ def image_data(path,
690
694
filter_RGB_colourspaces ('^{0}$' .format (
691
695
re .escape (secondary_colourspace ))))
692
696
697
+ colourspace = (primary_colourspace if image_colourspace == 'Primary' else
698
+ secondary_colourspace )
699
+
693
700
RGB = load_image (path , image_decoding_cctf )
694
701
695
702
if saturate :
@@ -711,6 +718,14 @@ def image_data(path,
711
718
RGB [RGB != 0 ] = 1
712
719
RGB [np .any (RGB == 1 , axis = - 1 )] = 1
713
720
721
+ if out_of_pointer_gamut :
722
+ O_PG = is_within_pointer_gamut (
723
+ RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
724
+ colourspace .RGB_to_XYZ_matrix )).astype (np .int_ )
725
+ O_PG = 1 - O_PG
726
+ RGB [O_PG != 1 ] = 0
727
+ RGB [O_PG == 1 ] = 1
728
+
714
729
shape = RGB .shape
715
730
RGB = np .ravel (RGB [..., 0 :3 ].reshape (- 1 , 3 ))
716
731
RGB = np .around (RGB , np .finfo (COLOUR_DTYPE ).precision )
@@ -777,6 +792,7 @@ def RGB_image_scatter_visual(path,
777
792
colourspace_model = COLOURSPACE_MODEL ,
778
793
out_of_primary_colourspace_gamut = False ,
779
794
out_of_secondary_colourspace_gamut = False ,
795
+ out_of_pointer_gamut = False ,
780
796
sub_sampling = 25 ,
781
797
saturate = False ):
782
798
"""
@@ -807,6 +823,8 @@ def RGB_image_scatter_visual(path,
807
823
out_of_secondary_colourspace_gamut : bool, optional
808
824
Whether to only generate the out of secondary RGB colourspace gamut
809
825
visual geometry.
826
+ out_of_pointer_gamut : bool, optional
827
+ Whether to only generate the out of *Pointer's Gamut* visual geometry.
810
828
sub_sampling : int, optional
811
829
Consider every ``sub_sampling`` pixels of the image to generate the
812
830
visual geometry. Using a low number will yield a large quantity of
@@ -853,13 +871,22 @@ def RGB_image_scatter_visual(path,
853
871
854
872
RGB = RGB [np .any (np .logical_or (RGB_c < 0 , RGB_c > 1 ), axis = - 1 )]
855
873
874
+ if out_of_pointer_gamut :
875
+ O_PG = is_within_pointer_gamut (
876
+ RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
877
+ colourspace .RGB_to_XYZ_matrix )).astype (np .int_ )
878
+ O_PG = 1 - O_PG
879
+ RGB = RGB [O_PG == 1 ]
880
+
856
881
XYZ = RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
857
882
colourspace .RGB_to_XYZ_matrix )
883
+
858
884
vertices = colourspace_model_axis_reorder (
859
885
XYZ_to_colourspace_model_normalised (
860
886
XYZ , colourspace .whitepoint , colourspace_model ), colourspace_model )
861
887
862
- if out_of_primary_colourspace_gamut or out_of_secondary_colourspace_gamut :
888
+ if (out_of_primary_colourspace_gamut or
889
+ out_of_secondary_colourspace_gamut or out_of_pointer_gamut ):
863
890
RGB = np .ones (RGB .shape )
864
891
865
892
return buffer_geometry (position = vertices , color = RGB )
0 commit comments