Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit c855fbd

Browse files
committed
Merge branch 'feature/v0.1.2' into develop
2 parents 48609f0 + 40aaf1d commit c855fbd

File tree

6 files changed

+80
-8
lines changed

6 files changed

+80
-8
lines changed

app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def image_data_response(image):
241241
args.get('outOfPrimaryColourspaceGamut', False)),
242242
out_of_secondary_colourspace_gamut=_bool_to_bool(
243243
args.get('outOfSecondaryColourspaceGamut', False)),
244+
out_of_pointer_gamut=_bool_to_bool(
245+
args.get('outOfPointerGamut', False)),
244246
saturate=_bool_to_bool(args.get('saturate', False)))
245247

246248
response = Response(json_data, status=200, mimetype='application/json')
@@ -303,6 +305,8 @@ def RGB_image_scatter_visual_response(image):
303305
args.get('outOfPrimaryColourspaceGamut', False)),
304306
out_of_secondary_colourspace_gamut=_bool_to_bool(
305307
args.get('outOfSecondaryColourspaceGamut', False)),
308+
out_of_pointer_gamut=_bool_to_bool(
309+
args.get('outOfPointerGamut', False)),
306310
sub_sampling=int(args.get('subSampling', 25)),
307311
saturate=_bool_to_bool(args.get('saturate', False)),
308312
)

colour_analysis.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from colour import (Lab_to_XYZ, LCHab_to_Lab, LOG_DECODING_CURVES,
2020
POINTER_GAMUT_DATA, POINTER_GAMUT_ILLUMINANT,
2121
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)
2324
from colour.models import (XYZ_to_colourspace_model, function_gamma,
2425
function_linear)
2526
from colour.plotting import filter_cmfs, filter_RGB_colourspaces
@@ -38,10 +39,10 @@
3839
'COLOURSPACE_MODELS', 'COLOURSPACE_MODELS_LABELS', 'DECODING_CCTFS',
3940
'PRIMARY_COLOURSPACE', 'SECONDARY_COLOURSPACE', 'IMAGE_COLOURSPACE',
4041
'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',
4546
'RGB_image_scatter_visual', 'pointer_gamut_visual'
4647
]
4748

@@ -647,6 +648,7 @@ def image_data(path,
647648
image_decoding_cctf=IMAGE_DECODING_CCTF,
648649
out_of_primary_colourspace_gamut=False,
649650
out_of_secondary_colourspace_gamut=False,
651+
out_of_pointer_gamut=False,
650652
saturate=False):
651653
"""
652654
Returns given image RGB data or its out of gamut values formatted as
@@ -673,7 +675,9 @@ def image_data(path,
673675
values.
674676
out_of_secondary_colourspace_gamut : bool, optional
675677
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.
677681
saturate : bool, optional
678682
Whether to clip the image in domain [0, 1].
679683
@@ -690,6 +694,9 @@ def image_data(path,
690694
filter_RGB_colourspaces('^{0}$'.format(
691695
re.escape(secondary_colourspace))))
692696

697+
colourspace = (primary_colourspace if image_colourspace == 'Primary' else
698+
secondary_colourspace)
699+
693700
RGB = load_image(path, image_decoding_cctf)
694701

695702
if saturate:
@@ -711,6 +718,14 @@ def image_data(path,
711718
RGB[RGB != 0] = 1
712719
RGB[np.any(RGB == 1, axis=-1)] = 1
713720

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+
714729
shape = RGB.shape
715730
RGB = np.ravel(RGB[..., 0:3].reshape(-1, 3))
716731
RGB = np.around(RGB, np.finfo(COLOUR_DTYPE).precision)
@@ -777,6 +792,7 @@ def RGB_image_scatter_visual(path,
777792
colourspace_model=COLOURSPACE_MODEL,
778793
out_of_primary_colourspace_gamut=False,
779794
out_of_secondary_colourspace_gamut=False,
795+
out_of_pointer_gamut=False,
780796
sub_sampling=25,
781797
saturate=False):
782798
"""
@@ -807,6 +823,8 @@ def RGB_image_scatter_visual(path,
807823
out_of_secondary_colourspace_gamut : bool, optional
808824
Whether to only generate the out of secondary RGB colourspace gamut
809825
visual geometry.
826+
out_of_pointer_gamut : bool, optional
827+
Whether to only generate the out of *Pointer's Gamut* visual geometry.
810828
sub_sampling : int, optional
811829
Consider every ``sub_sampling`` pixels of the image to generate the
812830
visual geometry. Using a low number will yield a large quantity of
@@ -853,13 +871,22 @@ def RGB_image_scatter_visual(path,
853871

854872
RGB = RGB[np.any(np.logical_or(RGB_c < 0, RGB_c > 1), axis=-1)]
855873

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+
856881
XYZ = RGB_to_XYZ(RGB, colourspace.whitepoint, colourspace.whitepoint,
857882
colourspace.RGB_to_XYZ_matrix)
883+
858884
vertices = colourspace_model_axis_reorder(
859885
XYZ_to_colourspace_model_normalised(
860886
XYZ, colourspace.whitepoint, colourspace_model), colourspace_model)
861887

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):
863890
RGB = np.ones(RGB.shape)
864891

865892
return buffer_geometry(position=vertices, color=RGB)

dist/colour-analysis.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/visuals/image-scatter-visual.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ImageScatterVisual extends Visual {
2121
settings.outOfPrimaryColourspaceGamut || false;
2222
this._outOfSecondaryColourspaceGamut =
2323
settings.outOfSecondaryColourspaceGamut || false;
24+
this._outOfPointerGamut = settings.outOfPointerGamut || false;
2425
this._subSampling = settings.subSampling || 25;
2526
this._pointSize = settings.pointSize || 0.01;
2627
this._saturate = settings.saturate || false;
@@ -136,6 +137,15 @@ class ImageScatterVisual extends Visual {
136137
this.add();
137138
}
138139

140+
get outOfPointerGamut() {
141+
return this._outOfPointerGamut;
142+
}
143+
144+
set outOfPointerGamut(value) {
145+
this._outOfPointerGamut = value;
146+
this.add();
147+
}
148+
139149
get subSampling() {
140150
return this._subSampling;
141151
}
@@ -191,6 +201,7 @@ class ImageScatterVisual extends Visual {
191201
`outOfSecondaryColourspaceGamut=${
192202
this._outOfSecondaryColourspaceGamut
193203
}&` +
204+
`outOfPointerGamut=${this._outOfPointerGamut}&` +
194205
`subSampling=${this._subSampling}&` +
195206
`saturate=${this._saturate}&`
196207
);

src/visuals/image-visual.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ImageVisual extends Visual {
1919
settings.outOfPrimaryColourspaceGamut || false;
2020
this._outOfSecondaryColourspaceGamut =
2121
settings.outOfSecondaryColourspaceGamut || false;
22+
this._outOfPointerGamut = settings.outOfPointerGamut || false;
2223
this._saturate = settings.saturate || false;
2324

2425
this._depth = settings.depth || 0;
@@ -106,6 +107,15 @@ class ImageVisual extends Visual {
106107
this.add();
107108
}
108109

110+
get outOfPointerGamut() {
111+
return this._outOfPointerGamut;
112+
}
113+
114+
set outOfPointerGamut(value) {
115+
this._outOfPointerGamut = value;
116+
this.add();
117+
}
118+
109119
get saturate() {
110120
return this._saturate;
111121
}
@@ -144,6 +154,7 @@ class ImageVisual extends Visual {
144154
`outOfSecondaryColourspaceGamut=${
145155
this._outOfSecondaryColourspaceGamut
146156
}&` +
157+
`outOfPointerGamut=${this._outOfPointerGamut}&` +
147158
`saturate=${this._saturate}`
148159
);
149160
}

templates/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
this.imageDecodingCctf = imageDecodingCctf;
192192
this.outOfPrimaryColourspaceGamut = false;
193193
this.outOfSecondaryColourspaceGamut = false;
194+
this.outOfPointerGamut = false;
194195

195196
this.primaryColourspace = primaryColourspace;
196197
this.primaryColourspaceVisualWireframe = false;
@@ -402,6 +403,24 @@
402403
gamutView1.imageScatterOverlayVisual.outOfSecondaryColourspaceGamut = value;
403404
imageView1.imageOverlayVisual.outOfSecondaryColourspaceGamut = value;
404405
});
406+
407+
// Out of Pointer's Gamut
408+
var outOfPointerGamutController = overallFolder
409+
.add(controls, 'outOfPointerGamut')
410+
.name('Out of Pointer\'s Gamut')
411+
.onChange(function (value) {
412+
if (gamutView1.isLoading() || imageView1.isLoading()) {
413+
ColourAnalysis.warning('A visual is already loading!');
414+
controls.outOfPointerGamut =
415+
gamutView1.imageScatterOverlayVisual.outOfPointerGamut;
416+
outOfPointerGamutController.updateDisplay();
417+
return;
418+
}
419+
420+
gamutView1.imageScatterOverlayVisual.outOfPointerGamut = value;
421+
imageView1.imageOverlayVisual.outOfPointerGamut = value;
422+
});
423+
405424
// imageScatterFolder
406425
// .add(controls, 'imageScatterVisualSaturate')
407426
// .name('Clamp')

0 commit comments

Comments
 (0)