Created
December 31, 2016 04:40
-
-
Save KelSolaar/9b81bc83d3b074824d80f8eb17217779 to your computer and use it in GitHub Desktop.
Colour - RGB Colourspace Definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import colour | |
# Manual NPM Derivation | |
primaries=np.array([[0.1, 0.2], | |
[0.3, 0.4], | |
[0.5, 0.6]]) | |
whitepoint=np.array([0.5, 0.5]) | |
npm = colour.normalised_primary_matrix( | |
primaries, whitepoint) | |
RGB_COLOURSPACE_A = colour.RGB_Colourspace( | |
'RGB Colourspace A', | |
primaries=primaries, | |
whitepoint=whitepoint, | |
RGB_to_XYZ_matrix=npm, | |
XYZ_to_RGB_matrix=np.linalg.inv(npm)) | |
print(RGB_COLOURSPACE_A.RGB_to_XYZ_matrix) | |
# [[ 1.32458813e+14 -7.94752875e+14 6.62294063e+14] | |
# [ 2.64917625e+14 -1.05967050e+15 7.94752875e+14] | |
# [ 9.27211688e+14 -7.94752875e+14 -1.32458813e+14]] | |
# Automatic NPM Derivation | |
RGB_COLOURSPACE_B = colour.RGB_Colourspace( | |
'RGB Colourspace B', | |
primaries=np.array([[0.1, 0.2], | |
[0.3, 0.4], | |
[0.5, 0.6]]), | |
whitepoint=np.array([0.5, 0.5]), | |
use_derived_RGB_to_XYZ_matrix=True, | |
use_derived_XYZ_to_RGB_matrix=True) | |
print(RGB_COLOURSPACE_B.RGB_to_XYZ_matrix) | |
# [[ 1.32458813e+14 -7.94752875e+14 6.62294063e+14] | |
# [ 2.64917625e+14 -1.05967050e+15 7.94752875e+14] | |
# [ 9.27211688e+14 -7.94752875e+14 -1.32458813e+14]] | |
# If you need to plot them, etc... you need to make them available to the API this way: | |
colour.RGB_COLOURSPACES['RGB Colourspace A'] = RGB_COLOURSPACE_A | |
colour.RGB_COLOURSPACES['RGB Colourspace B'] = RGB_COLOURSPACE_B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment