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

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: colour-science/colour-analysis-three.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a7c6d7c50900f11af8bef44e33bce40fef0eeb86
Choose a base ref
..
head repository: colour-science/colour-analysis-three.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9e2cdfd2bd535e39645d1441e10309ee96cb1cb2
Choose a head ref
Showing with 45 additions and 43 deletions.
  1. +1 −1 .pre-commit-config.yaml
  2. +18 −18 app.py
  3. +26 −24 colour_analysis.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/google/yapf
rev: v0.40.0
rev: v0.40.2
hooks:
- id: yapf
36 changes: 18 additions & 18 deletions app.py
Original file line number Diff line number Diff line change
@@ -242,8 +242,8 @@ def image_data_response(image):
args.get('outOfPrimaryColourspaceGamut', False)),
out_of_secondary_colourspace_gamut=_bool_to_bool(
args.get('outOfSecondaryColourspaceGamut', False)),
out_of_pointer_gamut=_bool_to_bool(args.get('outOfPointerGamut',
False)),
out_of_pointer_gamut=_bool_to_bool(
args.get('outOfPointerGamut', False)),
saturate=_bool_to_bool(args.get('saturate', False)))

response = Response(json_data, status=200, mimetype='application/json')
@@ -306,8 +306,8 @@ def RGB_image_scatter_visual_response(image):
args.get('outOfPrimaryColourspaceGamut', False)),
out_of_secondary_colourspace_gamut=_bool_to_bool(
args.get('outOfSecondaryColourspaceGamut', False)),
out_of_pointer_gamut=_bool_to_bool(args.get('outOfPointerGamut',
False)),
out_of_pointer_gamut=_bool_to_bool(
args.get('outOfPointerGamut', False)),
sub_sampling=int(args.get('subSampling', 25)),
saturate=_bool_to_bool(args.get('saturate', False)),
)
@@ -355,8 +355,8 @@ def pointer_gamut_visual_response():
"""

args = request.args
json_data = pointer_gamut_visual(colourspace_model=args.get(
'colourspaceModel', COLOURSPACE_MODEL), )
json_data = pointer_gamut_visual(
colourspace_model=args.get('colourspaceModel', COLOURSPACE_MODEL), )

response = Response(json_data, status=200, mimetype='application/json')
response.headers['X-Content-Length'] = len(json_data)
@@ -377,8 +377,8 @@ def visible_spectrum_visual_response():
"""

args = request.args
json_data = visible_spectrum_visual(colourspace_model=args.get(
'colourspaceModel', COLOURSPACE_MODEL), )
json_data = visible_spectrum_visual(
colourspace_model=args.get('colourspaceModel', COLOURSPACE_MODEL), )

response = Response(json_data, status=200, mimetype='application/json')
response.headers['X-Content-Length'] = len(json_data)
@@ -397,16 +397,16 @@ def index():
Index response.
"""

return render_template('index.html',
colour_analysis_js=os.environ.get(
'COLOUR_ANALYSIS_JS',
'/static/js/colour-analysis.js'),
image=sorted(os.listdir(IMAGES_DIRECTORY))[0],
primary_colourspace=PRIMARY_COLOURSPACE,
secondary_colourspace=SECONDARY_COLOURSPACE,
image_colourspace=IMAGE_COLOURSPACE,
image_decoding_cctf=IMAGE_CCTF_DECODING,
colourspace_model=COLOURSPACE_MODEL)
return render_template(
'index.html',
colour_analysis_js=os.environ.get('COLOUR_ANALYSIS_JS',
'/static/js/colour-analysis.js'),
image=sorted(os.listdir(IMAGES_DIRECTORY))[0],
primary_colourspace=PRIMARY_COLOURSPACE,
secondary_colourspace=SECONDARY_COLOURSPACE,
image_colourspace=IMAGE_COLOURSPACE,
image_decoding_cctf=IMAGE_CCTF_DECODING,
colourspace_model=COLOURSPACE_MODEL)


@APP.after_request
50 changes: 26 additions & 24 deletions colour_analysis.py
Original file line number Diff line number Diff line change
@@ -167,8 +167,8 @@
'hdr-CIELAB', 'hdr-IPT'}**
"""

DATA_POINTER_GAMUT = Lab_to_XYZ(LCHab_to_Lab(DATA_POINTER_GAMUT_VOLUME),
CCS_ILLUMINANT_POINTER_GAMUT)
DATA_POINTER_GAMUT = Lab_to_XYZ(
LCHab_to_Lab(DATA_POINTER_GAMUT_VOLUME), CCS_ILLUMINANT_POINTER_GAMUT)
"""
Pointer's Gamut data converted to *CIE XYZ* tristimulus values.
@@ -250,12 +250,13 @@ def XYZ_to_colourspace_model(XYZ, illuminant, model, **kwargs):
Colourspace model values.
"""

ijk = convert(XYZ,
'CIE XYZ',
model,
illuminant=illuminant,
verbose={'mode': 'Short'},
**kwargs)
ijk = convert(
XYZ,
'CIE XYZ',
model,
illuminant=illuminant,
verbose={'mode': 'Short'},
**kwargs)

if model == 'JzAzBz':
ijk /= XYZ_to_JzAzBz([1, 1, 1])[0]
@@ -446,10 +447,9 @@ def conform_primitive_dtype(primitive):
vertices, faces, outline = primitive

return (
vertices.astype([('position', np.float32, (3, )),
('uv', np.float32, (2, )),
('normal', np.float32, (3, )),
('colour', np.float32, (4, ))]),
vertices.astype(
[('position', np.float32, (3, )), ('uv', np.float32, (2, )),
('normal', np.float32, (3, )), ('colour', np.float32, (4, ))]),
faces.astype(np.uint32),
outline.astype(np.uint32),
)
@@ -582,13 +582,14 @@ def RGB_colourspace_volume_visual(colourspace=PRIMARY_COLOURSPACE,
filter_RGB_colourspaces(re.escape(colourspace)).values())

cube = conform_primitive_dtype(
primitive_cube(width_segments=segments,
height_segments=segments,
depth_segments=segments))
primitive_cube(
width_segments=segments,
height_segments=segments,
depth_segments=segments))

vertices = cube[0]['position'] + 0.5
faces = colourspace_model_faces_reorder(np.reshape(cube[1], (-1, 1)),
colourspace_model)
faces = colourspace_model_faces_reorder(
np.reshape(cube[1], (-1, 1)), colourspace_model)
RGB = cube[0]['colour']

XYZ = RGB_to_XYZ(
@@ -761,13 +762,14 @@ def spectral_locus_visual(colourspace=PRIMARY_COLOURSPACE,
colourspace_model,
), colourspace_model)

RGB = normalise_maximum(XYZ_to_RGB(
XYZ,
colourspace.whitepoint,
colourspace.whitepoint,
colourspace.matrix_XYZ_to_RGB,
),
axis=-1)
RGB = normalise_maximum(
XYZ_to_RGB(
XYZ,
colourspace.whitepoint,
colourspace.whitepoint,
colourspace.matrix_XYZ_to_RGB,
),
axis=-1)

return buffer_geometry(position=vertices, color=RGB)