Skip to content

Instantly share code, notes, and snippets.

@KelSolaar
Last active September 1, 2015 20:13
Show Gist options
  • Save KelSolaar/bf898442b9b37af965b4 to your computer and use it in GitHub Desktop.
Save KelSolaar/bf898442b9b37af965b4 to your computer and use it in GitHub Desktop.
ACES - XYZ Matrices
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Rec. 709\n",
"[[ 3.24100326 -1.53739899 -0.49861587]\n",
" [-0.96922426 1.87592999 0.04155422]\n",
" [ 0.05563942 -0.2040112 1.05714897]]\n",
"[[ 3.20976213 -1.55756431 -0.4958272 ]\n",
" [-0.97097971 1.88516233 0.03948918]\n",
" [ 0.05972118 -0.21010871 1.14312725]]\n",
"\n",
"\n",
"DCI-P3\n",
"[[ 2.72539403 -1.01800301 -0.4401632 ]\n",
" [-0.79516803 1.68973205 0.02264719]\n",
" [ 0.04124189 -0.08763902 1.10092938]]\n",
"[[ 2.66286214 -1.11031817 -0.42271645]\n",
" [-0.82282389 1.75861719 0.02502194]\n",
" [ 0.03932559 -0.08383443 1.03721743]]\n",
"\n",
"\n",
"Rec. 2020\n",
"[[ 1.71666343 -0.35567332 -0.25336809]\n",
" [-0.66667384 1.61645574 0.0157683 ]\n",
" [ 0.01764248 -0.04277698 0.94224328]]\n",
"[[ 1.69666139 -0.36554901 -0.24857509]\n",
" [-0.67040031 1.62348268 0.01503882]\n",
" [ 0.02063133 -0.04775565 1.01910748]]\n"
]
}
],
"source": [
"import numpy as np\n",
"import colour\n",
"\n",
"print('Rec. 709')\n",
"print(np.linalg.inv(colour.RGB_COLOURSPACES['Rec. 709'].RGB_to_XYZ_matrix))\n",
"\n",
"D60 = colour.ILLUMINANTS['cie_2_1931']['D60']\n",
"D65 = colour.ILLUMINANTS['cie_2_1931']['D65']\n",
"M = colour.chromatic_adaptation_matrix_VonKries(\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(D60)),\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(D65)),\n",
" transform='Bradford')\n",
"\n",
"print(np.linalg.inv(colour.dot_matrix(np.linalg.inv(M),\n",
" colour.RGB_COLOURSPACES['Rec. 709'].RGB_to_XYZ_matrix)))\n",
"\n",
"print('\\n')\n",
"\n",
"print('DCI-P3')\n",
"print(np.linalg.inv(colour.RGB_COLOURSPACES['DCI-P3'].RGB_to_XYZ_matrix))\n",
"\n",
"D60 = colour.ILLUMINANTS['cie_2_1931']['D60']\n",
"P3 = colour.ILLUMINANTS['cie_2_1931']['DCI-P3']\n",
"M = colour.chromatic_adaptation_matrix_VonKries(\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(D60)),\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(P3)),\n",
" transform='Bradford')\n",
"\n",
"print(np.linalg.inv(colour.dot_matrix(np.linalg.inv(M),\n",
" colour.RGB_COLOURSPACES['DCI-P3'].RGB_to_XYZ_matrix)))\n",
"\n",
"print('\\n')\n",
"\n",
"print('Rec. 2020')\n",
"print(np.linalg.inv(colour.RGB_COLOURSPACES['Rec. 2020'].RGB_to_XYZ_matrix))\n",
"M = colour.chromatic_adaptation_matrix_VonKries(\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(D60)),\n",
" colour.xyY_to_XYZ(colour.xy_to_xyY(D65)),\n",
" transform='Bradford')\n",
"\n",
"print(np.linalg.inv(colour.dot_matrix(np.linalg.inv(M),\n",
" colour.RGB_COLOURSPACES['Rec. 2020'].RGB_to_XYZ_matrix)))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment