Skip to content

Instantly share code, notes, and snippets.

@KelSolaar
Created March 8, 2015 00:32
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 KelSolaar/32f117237aefcb3c7198 to your computer and use it in GitHub Desktop.
Save KelSolaar/32f117237aefcb3c7198 to your computer and use it in GitHub Desktop.
Hue - Change
from pprint import pprint
from colour import XYZ_to_CIECAM02, CIECAM02_VIEWING_CONDITIONS, sRGB_to_XYZ
from colour.models.deprecated import RGB_to_HSV
XYZ = np.array([19.01, 20.00, 21.78])
XYZ_w = np.array([95.05, 100.00, 108.88])
L_A = 318.31
Y_b = 20.0
surround = CIECAM02_VIEWING_CONDITIONS['Average']
RGB = np.random.random(3)
RGB = np.array([0.1, 0.4, 1])
RGB_g, CIECAM02_H, HSV_H = [], [], []
for i in np.linspace(0.2, 2, 10):
RGB_c = RGB ** i
RGB_g.append(RGB_c)
CIECAM02_H.append(XYZ_to_CIECAM02(sRGB_to_XYZ(RGB_c), XYZ_w, L_A, Y_b, surround).H)
HSV_H.append(RGB_to_HSV(RGB_c)[0])
pprint(RGB_g)
pprint(CIECAM02_H)
pprint(HSV_H)
[array([ 0.63095734, 0.83255321, 1. ]),
array([ 0.39810717, 0.69314484, 1. ]),
array([ 0.25118864, 0.57707996, 1. ]),
array([ 0.15848932, 0.48044977, 1. ]),
array([ 0.1, 0.4, 1. ]),
array([ 0.06309573, 0.33302128, 1. ]),
array([ 0.03981072, 0.27725794, 1. ]),
array([ 0.02511886, 0.23083198, 1. ]),
array([ 0.01584893, 0.19217991, 1. ]),
array([ 0.01, 0.16, 1. ])]
[301.71022473499852,
305.03754788563873,
307.66791108080207,
309.48266207966486,
310.58957274037681,
311.17908942211699,
311.43581764636957,
311.49370669850163,
311.45041599570141,
311.3719308524586]
[0.57562214922566479,
0.58496948898334489,
0.59413141546907522,
0.60290030344435142,
0.61111111111111105,
0.61864938990436735,
0.62545131735579618,
0.63149774314357232,
0.63680489319977196,
0.64141414141414121]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment