{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ACES CTL - Figures" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[colour-science.org](http://colour-science.org) - September 03, 2016" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The purpose of this document is to illustrate the Academy Color Encoding System (ACES) CTL implementation internals and get a better understanding of the various transformations and state changes an image is going through while being processed with the *aces-dev* CTL codebase.\n", "\n", "The existing codebase is sparse when it comes to documentation and explanation on the choice of a lot of constants and parameters, this document attempts to shed some light on some of the system components.\n", "\n", "The *aces-dev* CTL implementation used is the following: https://github.com/hpd/aces-dev/commit/3579d014e60ff49426fc7e968cac68964f46dcfd\n", "\n", "The document currently explores the following aspects and modules:\n", "\n", "- [RRT](#RRT)\n", "- [ODT.Academy.RGBmonitor_100nits_dim.ctl](#ODT.Academy.RGBmonitor_100nits_dim)\n", "- [ACESlib.Tonescales.segmented_spline_c9_fwd](#ACESlib.Tonescales.segmented_spline_c9_fwd---*-ODTs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Methodology" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The CTL implementation is tested by processing two linear ramp images using *ctlrender* with the related CTL modules (or on the fly generated ones).\n", "\n", "The ramps have respectively [0, 1] and [1, 65504] domains and 16384 samples each.\n", "\n", "The processed output ramp images are loaded and plotted. If both output ramp images need to be plotted at same time (e.g. the RRT figure), they are concatenated together in a linear interpolator and log spaced samples are used to generate the figure so that the concatenated ramp low end coverage is increased.\n", "\n", "Usage of a Sprague (1880) fifth-order polynomial interpolator in place of the linear interpolator does not significantly change the results." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "//anaconda/envs/colour-2.7/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning:\n", "\n", "Matplotlib is building the font cache using fc-list. This may take a moment.\n", "\n" ] } ], "source": [ "import numpy as np\n", "import os\n", "import plotly.plotly as py\n", "import pylab\n", "import subprocess\n", "from collections import OrderedDict\n", "\n", "import colour" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CTL Initialisation" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "IO_DIRECTORY = os.path.join(os.getcwd(), 'resources', 'others', 'aces_ctl_analysis')\n", "\n", "not os.path.exists(IO_DIRECTORY) and os.makedirs(IO_DIRECTORY)\n", "\n", "CTL_ROOT_DIRECTORY = os.path.abspath(\n", " os.path.join(os.getcwd(), '..', 'aces-dev', 'transforms', 'ctl'))\n", "\n", "os.environ['CTL_MODULE_PATH'] = os.path.join(CTL_ROOT_DIRECTORY, 'lib')\n", "\n", "CTL_RENDER = 'ctlrender'\n", "CTL_DEFAULT_ARGUMENTS = ['-verbose', '-force']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def ctl_render(image_i, image_o, ctls, ctl_args=CTL_DEFAULT_ARGUMENTS):\n", " ctls_arguments = []\n", " for ctl in ctls:\n", " ctls_arguments.append('-ctl')\n", " ctls_arguments.append(ctl)\n", "\n", " output = subprocess.check_output(\n", " [CTL_RENDER] + ctl_args + [image_i, image_o] + ctls_arguments)\n", " \n", " return output" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Helpers & Resources" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "MINIMUM_REPR_NUMBER = 5.96e-08\n", "MAXIMUM_REPR_NUMBER = 65504\n", "\n", "DEFAULT_SAMPLE_COUNT = 16384\n", "SAMPLES_LDR = np.linspace(0, 1, DEFAULT_SAMPLE_COUNT)\n", "SAMPLES_HDR = np.linspace(1, MAXIMUM_REPR_NUMBER, DEFAULT_SAMPLE_COUNT)\n", "\n", "SAMPLES_LOG = np.logspace(np.log10(MINIMUM_REPR_NUMBER), \n", " np.log10(MAXIMUM_REPR_NUMBER), \n", " DEFAULT_SAMPLE_COUNT)\n", "\n", "PLOTLY_FOLDER = '/colour-science/aces_ctl'\n", "\n", "\n", "def write_linear_ramp_image(path, in_=0, out=1, samples=DEFAULT_SAMPLE_COUNT):\n", " a = np.linspace(in_, out, samples)[np.newaxis, ...]\n", " a = colour.tstack((a, a, a))\n", " colour.write_image(a, path)\n", "\n", " \n", "def concatenated_interpolator(\n", " a, \n", " b,\n", " samples_a=SAMPLES_LDR, \n", " samples_b=SAMPLES_HDR,\n", " interpolator=colour.LinearInterpolator):\n", " \n", " x = np.hstack((samples_a, samples_b))\n", " y = np.hstack((a, b))\n", " \n", " return colour.Extrapolator(interpolator(x, y))\n", "\n", "\n", "LINEAR_RAMP_LDR_PATH = os.path.join(IO_DIRECTORY, 'linear_ramp_ldr.exr')\n", "LINEAR_RAMP_HDR_PATH = os.path.join(IO_DIRECTORY, 'linear_ramp_hdr.exr')\n", "\n", "write_linear_ramp_image(LINEAR_RAMP_LDR_PATH, 0, 1)\n", "write_linear_ramp_image(LINEAR_RAMP_HDR_PATH, 1, MAXIMUM_REPR_NUMBER)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Figures" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### RRT" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "//anaconda/envs/colour-2.7/lib/python2.7/site-packages/plotly/plotly/plotly.py:1443: UserWarning:\n", "\n", "Estimated Draw Time Slow\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "The draw time for this plot will be slow for clients without much RAM.\n" ] }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RRT_LDR_PATH = os.path.join(IO_DIRECTORY, 'RRT_ldr.exr')\n", "RRT_HDR_PATH = os.path.join(IO_DIRECTORY, 'RRT_hdr.exr')\n", "\n", "ctl_render(LINEAR_RAMP_LDR_PATH, \n", " RRT_LDR_PATH,\n", " (os.path.join(CTL_ROOT_DIRECTORY, 'rrt', 'RRT.ctl'), ))\n", "ctl_render(LINEAR_RAMP_HDR_PATH, \n", " RRT_HDR_PATH,\n", " (os.path.join(CTL_ROOT_DIRECTORY, 'rrt', 'RRT.ctl'), ))\n", "\n", "RRT_LDR_IMAGE = colour.read_image(RRT_LDR_PATH)\n", "RRT_HDR_IMAGE = colour.read_image(RRT_HDR_PATH)\n", "\n", "name = 'RRT'\n", "figure = pylab.figure()\n", "for i, axis in enumerate(('R', 'G', 'B')):\n", " RRT_interpolator = concatenated_interpolator(\n", " RRT_LDR_IMAGE[..., i], RRT_HDR_IMAGE[..., i])\n", " pylab.loglog(SAMPLES_LOG, \n", " RRT_interpolator(SAMPLES_LOG), \n", " label=axis, \n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'RRT - Gradient - [0, 1]'\n", "\n", "figure = pylab.figure()\n", "\n", "pylab.plot(SAMPLES_LDR, \n", " np.gradient(RRT_LDR_IMAGE[..., 0]), \n", " linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ODT.Academy.RGBmonitor_100nits_dim" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ODT_RGB_MONITOR_LDR_PATH = os.path.join(IO_DIRECTORY, 'ODT_rgb_monitor_ldr.exr')\n", "\n", "ctl_render(LINEAR_RAMP_LDR_PATH, \n", " ODT_RGB_MONITOR_LDR_PATH,\n", " (os.path.join(CTL_ROOT_DIRECTORY, 'odt', 'rgbMonitor', 'ODT.Academy.RGBmonitor_100nits_dim.ctl'), ))\n", "\n", "name = 'ODT.Academy.RGBmonitor_100nits_dim'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_LDR, \n", " colour.read_image(ODT_RGB_MONITOR_LDR_PATH)[..., 0], \n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ODT.Academy.RGBmonitor_100nits_dim - Gradient'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_LDR, \n", " np.gradient(colour.read_image(ODT_RGB_MONITOR_LDR_PATH)[..., 0]), \n", " linewidth=2)\n", "\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ODT.Academy.RGBmonitor_100nits_dim(RRT)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ODT_RGB_MONITOR_RRT_LDR_PATH = os.path.join(IO_DIRECTORY, 'ODT_rgb_monitor_RRT_ldr.exr')\n", "\n", "ctl_render(LINEAR_RAMP_LDR_PATH, \n", " ODT_RGB_MONITOR_RRT_LDR_PATH,\n", " (os.path.join(CTL_ROOT_DIRECTORY, 'rrt', 'RRT.ctl'),\n", " os.path.join(CTL_ROOT_DIRECTORY, 'odt', 'rgbMonitor', 'ODT.Academy.RGBmonitor_100nits_dim.ctl')))\n", "\n", "name = 'ODT.Academy.RGBmonitor_100nits_dim(RRT)'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_LDR, \n", " colour.read_image(ODT_RGB_MONITOR_RRT_LDR_PATH)[..., 0], \n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.Tonescales.segmented_spline_c9_fwd - * ODTs" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The draw time for this plot will be slow for clients without much RAM.\n" ] }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ODT_SEGMENTED_SPLINE_PARAMETERS_CTL = (\n", " 'ODT_48nits', 'ODT_1000nits', 'ODT_2000nits', 'ODT_4000nits')\n", "\n", "SEGMENTED_SPLINE_C9_FWD_CTL = \"\"\"\n", "// Colour - CTL - segmented_spline_c9_fwd\n", "\n", "import \"ACESlib.Utilities\";\n", "import \"ACESlib.Tonescales\";\n", "\n", "void main \n", "(\n", " input varying float rIn, \n", " input varying float gIn, \n", " input varying float bIn, \n", " input varying float aIn,\n", " output varying float rOut,\n", " output varying float gOut,\n", " output varying float bOut,\n", " output varying float aOut\n", ")\n", "{{\n", " rOut = segmented_spline_c9_fwd(rIn, {0});\n", " gOut = segmented_spline_c9_fwd(gIn, {0});\n", " bOut = segmented_spline_c9_fwd(bIn, {0});\n", " aOut = aIn;\n", "}}\n", "\"\"\"[1:]\n", "\n", "SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS = OrderedDict()\n", "for parameter in ODT_SEGMENTED_SPLINE_PARAMETERS_CTL:\n", " segmented_spline_c9_fwd_ctl_path = os.path.join(\n", " IO_DIRECTORY, 'segmented_spline_c9_fwd_{0}.ctl'.format(\n", " parameter))\n", "\n", " with open(segmented_spline_c9_fwd_ctl_path, 'w') as file_:\n", " file_.write(SEGMENTED_SPLINE_C9_FWD_CTL.format(parameter))\n", "\n", " segmented_spline_c9_fwd_ldr_image_path = os.path.join(\n", " IO_DIRECTORY, 'segmented_spline_c9_fwd_{0}_ldr.exr'.format(\n", " parameter))\n", " segmented_spline_c9_fwd_hdr_image_path = os.path.join(\n", " IO_DIRECTORY, 'segmented_spline_c9_fwd_{0}_hdr.exr'.format(\n", " parameter))\n", "\n", " ctl_render(LINEAR_RAMP_LDR_PATH, \n", " segmented_spline_c9_fwd_ldr_image_path,\n", " (segmented_spline_c9_fwd_ctl_path, ))\n", " ctl_render(LINEAR_RAMP_HDR_PATH, \n", " segmented_spline_c9_fwd_hdr_image_path,\n", " (segmented_spline_c9_fwd_ctl_path, ))\n", "\n", " SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS[parameter] = (\n", " concatenated_interpolator(\n", " colour.read_image(segmented_spline_c9_fwd_ldr_image_path)[..., 0],\n", " colour.read_image(segmented_spline_c9_fwd_hdr_image_path)[..., 0]))\n", "\n", "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - [{0}, {1}]'.format(\n", " MINIMUM_REPR_NUMBER, MAXIMUM_REPR_NUMBER)\n", "figure = pylab.figure()\n", "for name_i, interpolator in SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS.items():\n", " pylab.loglog(SAMPLES_LOG, \n", " interpolator(SAMPLES_LOG), \n", " label=name_i, \n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.Tonescales.segmented_spline_c9_fwd - 48nits ODT - Zoom [0, 0.18]" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "SAMPLES_ZOOM = np.linspace(0, 0.18, DEFAULT_SAMPLE_COUNT)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_48nits'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_ZOOM, \n", " SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_48nits'](SAMPLES_ZOOM), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_48nits - Gradient'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_ZOOM,\n", " np.gradient(SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_48nits'](SAMPLES_ZOOM)), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.Tonescales.segmented_spline_c9_fwd - 1000nits ODT - Zoom [0, 0.18]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_1000nits'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_ZOOM, \n", " SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_1000nits'](SAMPLES_ZOOM), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_1000nits - Gradient'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_ZOOM,\n", " np.gradient(SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_1000nits'](SAMPLES_ZOOM)), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.Tonescales.segmented_spline_c9_fwd - 2000nits ODT - Zoom [0, 0.18]" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_2000nits'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_ZOOM, \n", " SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_2000nits'](SAMPLES_ZOOM), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_2000nits - Gradient'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_ZOOM,\n", " np.gradient(SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_2000nits'](SAMPLES_ZOOM)), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.Tonescales.segmented_spline_c9_fwd - 4000nits ODT - Zoom [0, 0.18]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_4000nits'\n", "figure = pylab.figure()\n", "pylab.loglog(SAMPLES_ZOOM, \n", " SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_4000nits'](SAMPLES_ZOOM), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.xlabel('Input - Log')\n", "pylab.ylabel('Output - Log')\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "name = 'ACESlib.Tonescales.segmented_spline_c9_fwd - ODT_4000nits - Gradient'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_ZOOM,\n", " np.gradient(SEGMENTED_SPLINE_C9_FWD_INTERPOLATORS['ODT_4000nits'](SAMPLES_ZOOM)), \n", " label=name_i,\n", " linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ACESlib.ODT_Common.darkSurround_to_dimSurround" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "DARKSURROUND_TO_DIMSURROUND_CTL = \"\"\"\n", "// Colour - CTL - darkSurround_to_dimSurround\n", "\n", "import \"ACESlib.Utilities\";\n", "import \"ACESlib.Transform_Common\";\n", "import \"ACESlib.ODT_Common\";\n", "\n", "void main \n", "(\n", " input varying float rIn, \n", " input varying float gIn, \n", " input varying float bIn, \n", " input varying float aIn,\n", " output varying float rOut,\n", " output varying float gOut,\n", " output varying float bOut,\n", " output varying float aOut\n", ")\n", "{{\n", " float rgb[3];\n", " rgb[0] = rIn;\n", " rgb[1] = gIn;\n", " rgb[2] = bIn;\n", " \n", " rgb = darkSurround_to_dimSurround(rgb);\n", "\n", " rOut = rgb[0];\n", " gOut = rgb[1];\n", " bOut = rgb[2];\n", " aOut = aIn;\n", "}}\n", "\"\"\"[1:]\n", "\n", "DARKSURROUND_TO_DIMSURROUND_CTL_PATH = os.path.join(\n", " IO_DIRECTORY, 'darkSurround_to_dimSurround.ctl')\n", "\n", "with open(DARKSURROUND_TO_DIMSURROUND_CTL_PATH, 'w') as file_:\n", " file_.write(DARKSURROUND_TO_DIMSURROUND_CTL)\n", " \n", "DARKSURROUND_TO_DIMSURROUND_LDR_PATH = os.path.join(IO_DIRECTORY, 'darksurround_to_dimsurround_ldr.exr')\n", "\n", "ctl_render(LINEAR_RAMP_LDR_PATH, \n", " DARKSURROUND_TO_DIMSURROUND_LDR_PATH,\n", " (DARKSURROUND_TO_DIMSURROUND_CTL_PATH, ))\n", "\n", "name = 'ACESlib.ODT_Common.darkSurround_to_dimSurround'\n", "figure = pylab.figure()\n", "pylab.plot(SAMPLES_LDR,\n", " colour.read_image(DARKSURROUND_TO_DIMSURROUND_LDR_PATH)[..., 0], \n", " label='darkSurround_to_dimSurround',\n", " linewidth=2)\n", "pylab.plot(SAMPLES_LDR, SAMPLES_LDR, label='f(x)=x', linewidth=2)\n", "pylab.title(name)\n", "py.iplot_mpl(figure, filename='/'.join((PLOTLY_FOLDER, name)))" ] } ], "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.12" } }, "nbformat": 4, "nbformat_minor": 0 }