Skip to content

Commit

Permalink
Update example Jupyter Notebook to utilize the updated colour API for…
Browse files Browse the repository at this point in the history
… creating ColourChecker object and performing colourspace conversions.
  • Loading branch information
CorbanSwain authored and KelSolaar committed Sep 8, 2023
1 parent 68429ce commit 39612a9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions colour_checker_detection/examples/examples_detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,36 @@
"REFERENCE_COLOUR_CHECKER = colour.CCS_COLOURCHECKERS[\n",
" 'ColorChecker24 - After November 2014']\n",
"\n",
"colour_checker_rows = REFERENCE_COLOUR_CHECKER.rows\n",
"colour_checker_columns = REFERENCE_COLOUR_CHECKER.columns\n",
"\n",
"# NOTE: The reference swatches values as produced by the \"colour.XYZ_to_RGB\"\n",
"# definition are linear by default.\n",
"# See https://github.com/colour-science/colour-checker-detection/discussions/59\n",
"# for more information.\n",
"REFERENCE_SWATCHES = colour.XYZ_to_RGB(\n",
" colour.xyY_to_XYZ(list(REFERENCE_COLOUR_CHECKER.data.values())),\n",
" REFERENCE_COLOUR_CHECKER.illuminant, D65,\n",
" colour.RGB_COLOURSPACES['sRGB'].matrix_XYZ_to_RGB)\n",
" 'sRGB', REFERENCE_COLOUR_CHECKER.illuminant)\n",
"\n",
"for i, swatches in enumerate(SWATCHES):\n",
" swatches_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
" swatches, D65, D65, colour.RGB_COLOURSPACES['sRGB'].matrix_RGB_to_XYZ))\n",
" swatches, 'sRGB', D65))\n",
"\n",
" colour_checker = colour.characterisation.ColourChecker(\n",
" os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i]),\n",
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_xyY)),\n",
" D65)\n",
" D65, colour_checker_rows, colour_checker_columns)\n",
" \n",
" colour.plotting.plot_multi_colour_checkers(\n",
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
" \n",
" swatches_f = colour.colour_correction(swatches, swatches, REFERENCE_SWATCHES)\n",
" swatches_f_xyY = colour.XYZ_to_xyY(colour.RGB_to_XYZ(\n",
" swatches_f, D65, D65, colour.RGB_COLOURSPACES['sRGB'].matrix_RGB_to_XYZ))\n",
" swatches_f, 'sRGB', D65))\n",
" colour_checker = colour.characterisation.ColourChecker(\n",
" '{0} - CC'.format(os.path.basename(COLOUR_CHECKER_IMAGE_PATHS[i])),\n",
" dict(zip(REFERENCE_COLOUR_CHECKER.data.keys(), swatches_f_xyY)),\n",
" D65)\n",
" D65, colour_checker_rows, colour_checker_columns)\n",
" \n",
" colour.plotting.plot_multi_colour_checkers(\n",
" [REFERENCE_COLOUR_CHECKER, colour_checker])\n",
Expand Down

0 comments on commit 39612a9

Please sign in to comment.