77loaded by "Three.js".
88"""
99
10- from __future__ import division
11-
1210import json
1311import numpy as np
1412import os
1513import re
16- from werkzeug . contrib . cache import SimpleCache
14+ from cachelib import SimpleCache
1715
18- from colour import (ILLUMINANTS , CCTF_DECODINGS , Lab_to_XYZ , LCHab_to_Lab ,
19- POINTER_GAMUT_DATA , POINTER_GAMUT_ILLUMINANT ,
16+ from colour import (CCS_ILLUMINANTS , CCTF_DECODINGS , Lab_to_XYZ , LCHab_to_Lab ,
2017 RGB_COLOURSPACES , RGB_to_RGB , RGB_to_XYZ , XYZ_to_RGB ,
2118 XYZ_to_JzAzBz , XYZ_to_OSA_UCS , convert ,
2219 is_within_pointer_gamut , read_image )
23- from colour .models import linear_function
20+ from colour .models import (CCS_ILLUMINANT_POINTER_GAMUT ,
21+ DATA_POINTER_GAMUT_VOLUME , linear_function )
2422from colour .plotting import filter_cmfs , filter_RGB_colourspaces
2523from colour .utilities import (CaseInsensitiveMapping , as_float_array ,
2624 first_item , normalise_maximum , tsplit , tstack )
2725from colour .volume import XYZ_outer_surface
2826
2927__author__ = 'Colour Developers'
30- __copyright__ = 'Copyright (C) 2018-2019 - Colour Developers'
28+ __copyright__ = 'Copyright (C) 2018-2020 - Colour Developers'
3129__license__ = 'New BSD License - https://opensource.org/licenses/BSD-3-Clause'
3230__maintainer__ = 'Colour Developers'
33- __email__ = 'colour-science@googlegroups.com '
31+ __email__ = 'colour-developers@colour-science.org '
3432__status__ = 'Production'
3533
3634__all__ = [
8886COLOURSPACE_MODELS = ('CAM02LCD' , 'CAM02SCD' , 'CAM02UCS' , 'CAM16LCD' ,
8987 'CAM16SCD' , 'CAM16UCS' , 'CIE XYZ' , 'CIE xyY' , 'CIE Lab' ,
9088 'CIE Luv' , 'CIE UCS' , 'CIE UVW' , 'DIN 99' , 'Hunter Lab' ,
91- 'Hunter Rdab' , 'ICTCP' , 'IPT ' , 'JzAzBz ' , 'OSA UCS ' ,
92- 'hdr-CIELAB' , 'hdr-IPT' )
89+ 'Hunter Rdab' , 'ICTCP' , 'IGPGTG ' , 'IPT ' , 'JzAzBz ' ,
90+ 'OSA UCS' , ' hdr-CIELAB' , 'hdr-IPT' )
9391"""
9492Reference colourspace models defining available colour transformations from
9593CIE XYZ tristimulus values.
9694
9795COLOURSPACE_MODELS : tuple
9896 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD', 'CAM16UCS',
9997 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS', 'CIE UVW', 'DIN 99',
100- 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT', 'JzAzBz', 'OSA UCS',
98+ 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG', ' IPT', 'JzAzBz', 'OSA UCS',
10199 'hdr-CIELAB', 'hdr-IPT'}**
102100"""
103101
118116 'Hunter Lab' : ('a' , 'L' , 'b' ),
119117 'Hunter Rdab' : ('a' , 'Rd' , 'b' ),
120118 'ICTCP' : ('CT' , 'I' , 'CP' ),
119+ 'IGPGTG' : ('PG' , 'IG' , 'TG' ),
121120 'IPT' : ('P' , 'I' , 'T' ),
122121 'JzAzBz' : ('Az' , 'Jz' , 'Bz' ),
123122 'OSA UCS' : ('j' , 'J' , 'g' ),
131130COLOURSPACE_MODELS : dict
132131 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD', 'CAM16UCS',
133132 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS', 'CIE UVW', 'DIN 99',
134- 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT', 'JzAzBz', 'OSA UCS',
133+ 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG', ' IPT', 'JzAzBz', 'OSA UCS',
135134 'hdr-CIELAB', 'hdr-IPT'}**
136135"""
137136
174173COLOURSPACE_MODEL : unicode
175174 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD', 'CAM16UCS',
176175 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS', 'CIE UVW', 'DIN 99',
177- 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT', 'JzAzBz', 'OSA UCS',
176+ 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG', ' IPT', 'JzAzBz', 'OSA UCS',
178177 'hdr-CIELAB', 'hdr-IPT'}**
179178"""
180179
181- POINTER_GAMUT_DATA = Lab_to_XYZ (
182- LCHab_to_Lab (POINTER_GAMUT_DATA ), POINTER_GAMUT_ILLUMINANT )
180+ DATA_POINTER_GAMUT = Lab_to_XYZ (
181+ LCHab_to_Lab (DATA_POINTER_GAMUT_VOLUME ), CCS_ILLUMINANT_POINTER_GAMUT )
183182"""
184183Pointer's Gamut data converted to *CIE XYZ* tristimulus values.
185184
186- POINTER_GAMUT_DATA : ndarray
185+ DATA_POINTER_GAMUT : ndarray
187186"""
188187
189188IMAGE_CACHE = SimpleCache (default_timeout = 60 * 24 * 7 )
@@ -246,8 +245,8 @@ def XYZ_to_colourspace_model(XYZ, illuminant, model, **kwargs):
246245 model : unicode
247246 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD',
248247 'CAM16UCS', 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS',
249- 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT ',
250- 'JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
248+ 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG ',
249+ 'IPT', ' JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
251250 Colourspace model to convert the *CIE XYZ* tristimulus values to.
252251
253252 Other Parameters
@@ -289,8 +288,8 @@ def colourspace_model_axis_reorder(a, model=None):
289288 model : unicode, optional
290289 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD',
291290 'CAM16UCS', 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS',
292- 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT ',
293- 'JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
291+ 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG ',
292+ 'IPT', ' JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
294293 Colourspace model.
295294
296295 Returns
@@ -306,8 +305,8 @@ def colourspace_model_axis_reorder(a, model=None):
306305 a = tstack ([j , k , i ])
307306 elif model in ('CAM02LCD' , 'CAM02SCD' , 'CAM02UCS' , 'CAM16LCD' , 'CAM16SCD' ,
308307 'CAM16UCS' , 'CIE Lab' , 'CIE LCHab' , 'CIE Luv' , 'CIE LCHuv' ,
309- 'DIN 99' , 'Hunter Lab' , 'Hunter Rdab' , 'ICTCP' , 'IPT ' ,
310- 'JzAzBz' , 'OSA UCS' , 'hdr-CIELAB' , 'hdr-IPT' ):
308+ 'DIN 99' , 'Hunter Lab' , 'Hunter Rdab' , 'ICTCP' , 'IGPGTG ' ,
309+ 'IPT' , ' JzAzBz' , 'OSA UCS' , 'hdr-CIELAB' , 'hdr-IPT' ):
311310 a = tstack ([k , i , j ])
312311
313312 return a
@@ -324,8 +323,8 @@ def colourspace_model_faces_reorder(a, model=None):
324323 model : unicode, optional
325324 **{'CAM02LCD', 'CAM02SCD', 'CAM02UCS', 'CAM16LCD', 'CAM16SCD',
326325 'CAM16UCS', 'CIE XYZ', 'CIE xyY', 'CIE Lab', 'CIE Luv', 'CIE UCS',
327- 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IPT ',
328- 'JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
326+ 'CIE UVW', 'DIN 99', 'Hunter Lab', 'Hunter Rdab', 'ICTCP', 'IGPGTG ',
327+ 'IPT', ' JzAzBz', 'OSA UCS', 'hdr-CIELAB', 'hdr-IPT'}**,
329328 Colourspace model.
330329
331330 Returns
@@ -384,13 +383,13 @@ def buffer_geometry(**kwargs):
384383 """
385384 Returns given geometry formatted as *JSON* compatible with *Three.js*
386385 `BufferGeometryLoader <https://threejs.org/docs/#api/loaders/\
387- BufferGeometryLoader>`_ .
386+ BufferGeometryLoader>`__ .
388387
389388 Other Parameters
390389 ----------------
391390 \\ **kwargs : dict, optional
392391 Valid attributes from `BufferGeometryLoader <https://threejs.org/docs/\
393- #api/loaders/BufferGeometryLoader>`_ .
392+ #api/loaders/BufferGeometryLoader>`__ .
394393
395394 Returns
396395 -------
@@ -644,7 +643,8 @@ def create_box(width=1,
644643 colors = np .hstack ([
645644 np .reshape (
646645 np .interp (colors , (np .min (colors ), np .max (colors )), (0 , 1 )),
647- positions .shape ),
646+ positions .shape ,
647+ ),
648648 np .ones ((positions .shape [0 ], 1 ))
649649 ])
650650
@@ -733,8 +733,12 @@ def image_data(path,
733733
734734 if out_of_pointer_gamut :
735735 O_PG = is_within_pointer_gamut (
736- RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
737- colourspace .RGB_to_XYZ_matrix )).astype (np .int_ )
736+ RGB_to_XYZ (
737+ RGB ,
738+ colourspace .whitepoint ,
739+ colourspace .whitepoint ,
740+ colourspace .matrix_RGB_to_XYZ ,
741+ )).astype (np .int_ )
738742 O_PG = 1 - O_PG
739743 RGB [O_PG != 1 ] = 0
740744 RGB [O_PG == 1 ] = 1
@@ -788,11 +792,18 @@ def RGB_colourspace_volume_visual(colourspace=PRIMARY_COLOURSPACE,
788792 np .reshape (cube [1 ], (- 1 , 1 )), colourspace_model )
789793 RGB = cube [0 ]['colour' ]
790794
791- XYZ = RGB_to_XYZ (vertices , colourspace .whitepoint , colourspace .whitepoint ,
792- colourspace .RGB_to_XYZ_matrix )
795+ XYZ = RGB_to_XYZ (
796+ vertices ,
797+ colourspace .whitepoint ,
798+ colourspace .whitepoint ,
799+ colourspace .matrix_RGB_to_XYZ ,
800+ )
793801 vertices = colourspace_model_axis_reorder (
794- XYZ_to_colourspace_model (XYZ , colourspace .whitepoint ,
795- colourspace_model ), colourspace_model )
802+ XYZ_to_colourspace_model (
803+ XYZ ,
804+ colourspace .whitepoint ,
805+ colourspace_model ,
806+ ), colourspace_model )
796807
797808 return buffer_geometry (position = vertices , color = RGB , index = faces )
798809
@@ -884,17 +895,28 @@ def RGB_image_scatter_visual(path,
884895
885896 if out_of_pointer_gamut :
886897 O_PG = is_within_pointer_gamut (
887- RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
888- colourspace .RGB_to_XYZ_matrix )).astype (np .int_ )
898+ RGB_to_XYZ (
899+ RGB ,
900+ colourspace .whitepoint ,
901+ colourspace .whitepoint ,
902+ colourspace .matrix_RGB_to_XYZ ,
903+ )).astype (np .int_ )
889904 O_PG = 1 - O_PG
890905 RGB = RGB [O_PG == 1 ]
891906
892- XYZ = RGB_to_XYZ (RGB , colourspace .whitepoint , colourspace .whitepoint ,
893- colourspace .RGB_to_XYZ_matrix )
907+ XYZ = RGB_to_XYZ (
908+ RGB ,
909+ colourspace .whitepoint ,
910+ colourspace .whitepoint ,
911+ colourspace .matrix_RGB_to_XYZ ,
912+ )
894913
895914 vertices = colourspace_model_axis_reorder (
896- XYZ_to_colourspace_model (XYZ , colourspace .whitepoint ,
897- colourspace_model ), colourspace_model )
915+ XYZ_to_colourspace_model (
916+ XYZ ,
917+ colourspace .whitepoint ,
918+ colourspace_model ,
919+ ), colourspace_model )
898920
899921 if (out_of_primary_colourspace_gamut or
900922 out_of_secondary_colourspace_gamut or out_of_pointer_gamut ):
@@ -934,12 +956,19 @@ def spectral_locus_visual(colourspace=PRIMARY_COLOURSPACE,
934956 XYZ = np .vstack ([XYZ , XYZ [0 , ...]])
935957
936958 vertices = colourspace_model_axis_reorder (
937- XYZ_to_colourspace_model (XYZ , colourspace .whitepoint ,
938- colourspace_model ), colourspace_model )
959+ XYZ_to_colourspace_model (
960+ XYZ ,
961+ colourspace .whitepoint ,
962+ colourspace_model ,
963+ ), colourspace_model )
939964
940965 RGB = normalise_maximum (
941- XYZ_to_RGB (XYZ , colourspace .whitepoint , colourspace .whitepoint ,
942- colourspace .XYZ_to_RGB_matrix ),
966+ XYZ_to_RGB (
967+ XYZ ,
968+ colourspace .whitepoint ,
969+ colourspace .whitepoint ,
970+ colourspace .matrix_XYZ_to_RGB ,
971+ ),
943972 axis = - 1 )
944973
945974 return buffer_geometry (position = vertices , color = RGB )
@@ -960,15 +989,16 @@ def pointer_gamut_visual(colourspace_model='CIE xyY'):
960989 *Pointer's Gamut* visual geometry formatted as *JSON*.
961990 """
962991
963- pointer_gamut_data = np .reshape (POINTER_GAMUT_DATA , (16 , - 1 , 3 ))
992+ data_pointer_gamut = np .reshape (DATA_POINTER_GAMUT , (16 , - 1 , 3 ))
964993 vertices = []
965994 for i in range (16 ):
966995 section = colourspace_model_axis_reorder (
967996 XYZ_to_colourspace_model (
968997 np .vstack (
969- [pointer_gamut_data [i ], pointer_gamut_data [i ][0 , ...]]),
970- POINTER_GAMUT_ILLUMINANT , colourspace_model ),
971- colourspace_model )
998+ [data_pointer_gamut [i ], data_pointer_gamut [i ][0 , ...]]),
999+ CCS_ILLUMINANT_POINTER_GAMUT ,
1000+ colourspace_model ,
1001+ ), colourspace_model )
9721002
9731003 vertices .append (list (zip (section , section [1 :])))
9741004
@@ -995,8 +1025,10 @@ def visible_spectrum_visual(colourspace_model='CIE xyY'):
9951025 XYZ = XYZ_outer_surface ()
9961026 vertices = colourspace_model_axis_reorder (
9971027 XYZ_to_colourspace_model (
998- XYZ , ILLUMINANTS ['CIE 1931 2 Degree Standard Observer' ]['E' ],
999- colourspace_model ), colourspace_model )
1028+ XYZ ,
1029+ CCS_ILLUMINANTS ['CIE 1931 2 Degree Standard Observer' ]['E' ],
1030+ colourspace_model ,
1031+ ), colourspace_model )
10001032
10011033 vertices = as_float_array (list (zip (vertices , vertices [1 :])))
10021034
0 commit comments