Skip to content

Instantly share code, notes, and snippets.

@DavidEWarrenPhD
Created November 9, 2017 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidEWarrenPhD/6f80ad640228ee1e659a635498e67314 to your computer and use it in GitHub Desktop.
Save DavidEWarrenPhD/6f80ad640228ee1e659a635498e67314 to your computer and use it in GitHub Desktop.
Dimensions of RGB colorspace in JCH using colorspacious
import colorspacious
import numpy as np
rgb = np.zeros((1, 256 ** 3, 3), dtype=np.uint8)
r = np.tile(np.arange(256), [256 ** 2])
g = np.tile(np.repeat(np.arange(256), 256), [256])
b = np.repeat(np.arange(256), 256 ** 2)
rgb[:, :, 0] = r
rgb[:, :, 1] = g
rgb[:, :, 2] = b
jch = colorspacious.cspace_convert(rgb, 'sRGB255', 'JCh') # Casts to double
print('JCH mins:', np.min(jch, axis=(0, 1)))
print('JCH maxs:', np.max(jch, axis=(0, 1)))
# JCH mins: [ 3.25891324e-22 4.07145763e-24 0.00000000e+00]
# JCH maxs: [ 99.99781855 111.3069358 359.99999388]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment