def create_ACES():
"""
- Object description.
+ Creates the *ACES2065-1* reference color space
Parameters
----------
- parameter : type
- Parameter description.
+ None
Returns
-------
- type
- Return value description.
+ ColorSpace
+ *ACES2065-1* and all its identifying information
"""
# Defining the reference colorspace.
max_value=1,
input_scale=1):
"""
- Creates the *ACEScc* colorspace.
+ Creates the *ACEScc* reference color space
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ name : str or unicode, optional
+ The name of the ColorSpace
+ min_value : float, optional
+ The minimum value to consider for the space
+ max_value : float, optional
+ The maximum value to consider for the space
+ input_scale : float, optional
+ A scale factor to divide input values
Returns
-------
- Colorspace
- *ACEScc* colorspace.
+ ColorSpace
+ *ACEScc* and all its identifying information
"""
cs = ColorSpace(name)
cleanup,
name='ACESproxy'):
"""
- Creates the *ACESproxy* colorspace.
+ Creates the *ACESproxy* color space
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ name : str or unicode, optional
+ The name of the ColorSpace
Returns
-------
- Colorspace
- *ACESproxy* colorspace.
+ ColorSpace
+ *ACESproxy* and all its identifying information
"""
cs = ColorSpace(name)
# -------------------------------------------------------------------------
def create_ACEScg():
"""
- Creates the *ACEScg* colorspace.
+ Creates the *ACEScg* color space
Parameters
----------
- parameter : type
- Parameter description.
+ None
Returns
-------
- Colorspace
- *ACEScg* colorspace.
+ ColorSpace
+ *ACEScg* and all its identifying information
"""
name = 'ACEScg'
bit_depth=10,
name='ADX'):
"""
- Creates the *ADX* colorspace.
+ Creates the *ADX* color space
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ bit_depth : int
+ Choose either 10 or 16 bit ADX
+ name : str or unicode, optional
+ The name of the ColorSpace
Returns
-------
- Colorspace
- *ADX* colorspace.
+ ColorSpace
+ *ADX* and all its identifying information
"""
name = '%s%s' % (name, bit_depth)
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ name : str or unicode, optional
+ The name of the ColorSpace
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
+ min_value : float, optional
+ The minimum value to consider for the space
+ max_value : float, optional
+ The maximum value to consider for the space
+ input_scale : float, optional
+ A scale factor to divide input values
+ middle_grey : float, optional
+ The middle of the dynamic range covered by the transfer function
+ min_exposure : float, optional
+ The offset from middle grey, in stops, that defines the low end of the dynamic
+ range covered by the transfer function
+ max_exposure : float, optional
+ The offset from middle grey, in stops, that defines the high end of the dynamic
+ range covered by the transfer function
Returns
-------
- Colorspace
+ ColorSpace
*Generic Log* colorspace.
"""
min_value=0.0,
max_value=1.0,
input_scale=1.0):
+ """
+ Creates the generic *Dolby PQ* colorspace.
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ name : str or unicode, optional
+ The name of the ColorSpace
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
+ min_value : float, optional
+ The minimum value to consider for the space
+ max_value : float, optional
+ The maximum value to consider for the space
+ input_scale : float, optional
+ A scale factor to divide input values
+
+ Returns
+ -------
+ ColorSpace
+ Generic *Dolby PQ* colorspace.
+ """
+
if aliases is None:
aliases = []
middle_grey=0.18,
min_exposure=-6.5,
max_exposure=6.5):
+ """
+ Creates a *Dolby PQ* colorspace that covers a specific dynamic range
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ name : str or unicode, optional
+ The name of the ColorSpace
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
+ min_value : float, optional
+ The minimum value to consider for the space
+ max_value : float, optional
+ The maximum value to consider for the space
+ input_scale : float, optional
+ A scale factor to divide input values
+ middle_grey : float, optional
+ The middle of the dynamic range covered by the transfer function
+ min_exposure : float, optional
+ The offset from middle grey, in stops, that defines the low end of the dynamic
+ range covered by the transfer function
+ max_exposure : float, optional
+ The offset from middle grey, in stops, that defines the high end of the dynamic
+ range covered by the transfer function
+
+ Returns
+ -------
+ ColorSpace
+ A *Dolby PQ* colorspace that covers a specific dynamic range
+ """
+
if aliases is None:
aliases = []
cleanup=True,
aliases=None):
"""
- Creates the *ACES LMT* colorspace.
+ Creates an *ACES Look Transform (LMT)* colorspace.
Parameters
----------
- parameter : type
- Parameter description.
+ lmt_name : str or unicode
+ The name of the Look Transform (LMT)
+ lmt_values : dict
+ A collection of values that define the Look Transform's attributes and behavior
+ shaper_info : dict
+ A collection of values that define the Shaper to use when generating LUTs to
+ represent the Look Transform
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_3d : int, optional
+ The resolution of generated 3D LUTs
+ cleanup : bool, optional
+ Whether or not to clean up the intermediate images
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
Returns
-------
- Colorspace
- *ACES LMT* colorspace.
+ ColorSpace
+ An *ACES LMT* colorspace.
"""
if aliases is None:
lmt_info,
cleanup):
"""
- Object description.
+ Create ColorSpaces representing the *ACES Look Transforms*
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ lut_resolution_3d : int
+ The resolution of generated 3D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
+ lmt_info : dict
+ A collection of values that define the Look Transforms that need to be
+ generated
Returns
-------
- type
- Return value description.
+ list of ColorSpaces
+ ColorSpaces representing the *ACES Look Transforms*
"""
colorspaces = []
cleanup=True,
aliases=None):
"""
- Object description.
+ Creates an *ACES Output Transform (RRT + ODT)* colorspace.
Parameters
----------
- parameter : type
- Parameter description.
+ odt_name : str or unicode
+ The name of the Output Transform (RRT + ODT)
+ odt_values : dict
+ A collection of values that define the Output Transform's attributes and behavior
+ shaper_info : dict
+ A collection of values that define the Shaper to use when generating LUTs to
+ represent the Output Transform
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_3d : int, optional
+ The resolution of generated 3D LUTs
+ cleanup : bool, optional
+ Whether or not to clean up the intermediate images
+ aliases : list of str or unicode, optional
+ The alias names to use for the ColorSpace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ An *ACES Output Transform (RRT + ODT)* colorspace.
"""
if aliases is None:
middle_grey,
min_exposure,
max_exposure):
+ """
+ Creates a *Log base 2* colorspace that covers a specific dynamic range
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ shaper_name : str or unicode, optional
+ The name of the ColorSpace
+ middle_grey : float
+ The middle of the dynamic range covered by the transfer function
+ min_exposure : float
+ The offset from middle grey, in stops, that defines the low end of the dynamic
+ range covered by the transfer function
+ max_exposure : float
+ The offset from middle grey, in stops, that defines the high end of the dynamic
+ range covered by the transfer function
+
+ Returns
+ -------
+ ColorSpace
+ A *Log base 2* colorspace that covers a specific dynamic range
+ """
+
colorspaces = []
shaper_data = {}
middle_grey,
min_exposure,
max_exposure):
+ """
+ Creates two *Dolby PQ* colorspaces, one with now gamut conversion, the other with
+ the conversion from *ACES* *AP0* to *AP1*
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ shaper_name : str or unicode, optional
+ The name of the ColorSpace
+ middle_grey : float
+ The middle of the dynamic range covered by the transfer function
+ min_exposure : float
+ The offset from middle grey, in stops, that defines the low end of the dynamic
+ range covered by the transfer function
+ max_exposure : float
+ The offset from middle grey, in stops, that defines the high end of the dynamic
+ range covered by the transfer function
+
+ Returns
+ -------
+ dict
+ Values defining a Shaper
+ list of ColorSpaces
+ A list of *Dolby PQ* colorspaces that covers a specific dynamic range
+ """
colorspaces = []
shaper_data = {}
shaper_data[dolby_pq_shaper_name] = dolby_pq_shaper_data
- # Defining the *Log2 shaper that includes the AP1* primaries.
+ # Defining the *Dolby PQ shaper that includes the AP1* primaries.
dolby_pq_shaper_api1_name = '%s - AP1' % dolby_pq_shaper_name
dolby_pq_shaper_api1_colorspace = copy.deepcopy(dolby_pq_shaper_colorspace)
lut_resolution_1d,
cleanup):
+ """
+ Creates sets of shaper colorspaces covering the *Log 2* and *Dolby PQ*
+ transfer functions and dynamic ranges suitable of use with the 48 nit,
+ 1000 nit, 2000 nit and 4000 nit *ACES Output Transforms*
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+
+ Returns
+ -------
+ list of dicts
+ Values defining a set of Shapers
+ list of ColorSpaces
+ A list of Shaper colorspaces that covers a varying dynamic ranges and
+ transfer functions
+ """
+
colorspaces = []
shaper_data = {}
linear_display_space,
log_display_space):
"""
- Object description.
+ Create ColorSpaces representing the *ACES Output Transforms*
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ lut_resolution_3d : int
+ The resolution of generated 3D LUTs
+ odt_info : dict
+ A collection of values that define the Output Transforms that need to be
+ generated
+ shaper_name : str or unicode, optional
+ The name of Shaper ColorSpace to use when generating LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+ linear_display_space : lstr or unicode
+ The name of the ColorSpace to use for the raw or linear View
+ log_display_space : lstr or unicode
+ The name of the ColorSpace to use for the log View
Returns
-------
- type
- Return value description.
+ list of ColorSpaces
+ ColorSpaces representing the *ACES Output Transforms*
+ list of dicts
+ Collections of names and ColorSpaces corresponding to the Displays and
+ Views
"""
colorspaces = []
def get_transform_info(ctl_transform):
"""
- Object description.
+ Returns the information stored in first couple of lines of an official
+ *ACES Transform* CTL file
Parameters
----------
- parameter : type
- Parameter description.
+ ctl_transform : str or unicode
+ The path to the CTL file to be scraped.
Returns
-------
- type
- Return value description.
+ tuple
+ Combination of Transform ID, User Name, User Name Prefix and Full/Legal
+ switch
"""
with open(ctl_transform, 'rb') as fp:
def get_ODTs_info(aces_ctl_directory):
"""
- Object description.
-
- For versions after WGR9.
+ Returns the information describing the names and CTL files associated with
+ the *ACES Output Transforms* in a given ACES release
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the base *ACES* CTL directory
Returns
-------
- type
- Return value description.
+ dict of dicts
+ Collecton of dicts, one describing each *ACES Output Transform*
"""
# TODO: Investigate usage of *files_walker* definition here.
def get_LMTs_info(aces_ctl_directory):
"""
- Object description.
-
- For versions after WGR9.
+ Returns the information describing the names and CTL files associated with
+ the *ACES Look Transforms* in a given ACES release
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the base *ACES* CTL directory
Returns
-------
- type
- Return value description.
+ dict of dicts
+ Collecton of dicts, one describing each *ACES Look Transform*
"""
# TODO: Investigate refactoring with previous definition.
shaper_name,
cleanup):
"""
- Generates the colorspace conversions.
+ Generates the *ACES* colorspaces, displays and views
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ lut_resolution_3d : int
+ The resolution of generated 3D LUTs
+ lmt_info : dict
+ A collection of values that define the Look Transforms that need to be
+ generated
+ odt_info : dict
+ A collection of values that define the Output Transforms that need to be
+ generated
+ shaper_name : str or unicode, optional
+ The name of Shaper ColorSpace to use when generating LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
Returns
-------
- type
- Return value description.
+ tuple
+ A collection of values defining
+ the reference colorspace : ACES
+ a list of the colorspaces created
+ a list of the displays created
+ a list of the general log colorspace
+ a list of the role assignments
+ the name of the default display
"""
colorspaces = []
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for ARRI cameras and encodings
"""
colorspaces = []
lut_resolution_1d,
aliases):
"""
- Object description.
-
- Canon-Log to ACES.
+ Creates colorspace covering the conversion from CLog to ACES, with various transfer
+ functions and encoding gamuts covered
Parameters
----------
- parameter : type
- Parameter description.
+ gamut : str
+ The name of the encoding gamut to use.
+ transfer_function : str
+ The name of the transfer function to use
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A ColorSpace container class referencing the LUTs, matrices and identifying
+ information for the requested colorspace.
"""
name = '%s - %s' % (transfer_function, gamut)
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for Canon cameras and encodings
"""
colorspaces = []
to_reference_values=None,
aliases=None):
"""
- Object description.
+ Creates a ColorSpace that only uses *Matrix Transforms*
Parameters
----------
- parameter : type
- Parameter description.
+ name : str, optional
+ Aliases for this colorspace
+ from_reference_values : list of matrices
+ List of matrices to convert from the reference colorspace to this space
+ to_reference_values : list of matrices
+ List of matrices to convert to the reference colorspace from this space
+ aliases : list of str, optional
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A *Matrix Transform*-based ColorSpace
"""
if from_reference_values is None:
lut_resolution_1d=1024,
aliases=None):
"""
- Object description.
+ Creates a ColorSpace that only uses transfer functions encoded as 1D LUTs
Parameters
----------
- parameter : type
- Parameter description.
+ name : str, optional
+ Aliases for this colorspace
+ transfer_function_name : str, optional
+ The name of the transfer function
+ transfer_function : function, optional
+ The transfer function to be evaluated
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A *LUT1D Transform*-based ColorSpace representing a transfer function
"""
if aliases is None:
to_reference_values=None,
aliases=None):
"""
- Object description.
+ Creates a ColorSpace that uses transfer functions encoded as 1D LUTs and
+ matrice
Parameters
----------
- parameter : type
- Parameter description.
+ name : str, optional
+ Aliases for this colorspace
+ transfer_function_name : str, optional
+ The name of the transfer function
+ transfer_function : function, optional
+ The transfer function to be evaluated
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ from_reference_values : list of matrices
+ List of matrices to convert from the reference colorspace to this space
+ to_reference_values : list of matrices
+ List of matrices to convert to the reference colorspace from this space
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A *Matrx and LUT1D Transform*-based ColorSpace representing a transfer
+ function and matrix
"""
if from_reference_values is None:
# Transfer functions for standard colorspaces.
def transfer_function_sRGB_to_linear(v):
+ """
+ The sRGB (IEC 61966-2-1) transfer function
+
+ Parameters
+ ----------
+ v : float
+ The normalized value to pass through the function
+
+ Returns
+ -------
+ float
+ A converted value
+ """
a = 1.055
b = 0.04045
d = 12.92
def transfer_function_Rec709_to_linear(v):
+ """
+ The Rec.709 transfer function
+
+ Parameters
+ ----------
+ v : float
+ The normalized value to pass through the function
+
+ Returns
+ -------
+ float
+ A converted value
+ """
a = 1.099
b = 0.018
d = 4.5
def transfer_function_Rec2020_10bit_to_linear(v):
+ """
+ The Rec.2020 10-bit transfer function
+
+ Parameters
+ ----------
+ v : float
+ The normalized value to pass through the function
+
+ Returns
+ -------
+ float
+ A converted value
+ """
a = 1.099
b = 0.018
d = 4.5
def transfer_function_Rec2020_12bit_to_linear(v):
+ """
+ The Rec.2020 12-bit transfer function
+
+ Parameters
+ ----------
+ v : float
+ The normalized value to pass through the function
+
+ Returns
+ -------
+ float
+ A converted value
+ """
a = 1.0993
b = 0.0181
d = 4.5
def transfer_function_Rec1886_to_linear(v):
+ """
+ The Rec.1886 transfer function
+
+ Parameters
+ ----------
+ v : float
+ The normalized value to pass through the function
+
+ Returns
+ -------
+ float
+ A converted value
+ """
g = 2.4
Lw = 1
Lb = 0
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for general colorspaces and encodings
"""
colorspaces = []
def create_raw():
+ """
+ Creates the *raw* color space
+
+ Parameters
+ ----------
+ None
+
+ Returns
+ -------
+ ColorSpace
+ *raw* and all its identifying information
+ """
# *Raw* utility space
name = 'Raw'
raw = ColorSpace(name)
lut_resolution_1d,
aliases):
"""
- Object description.
-
- Protune to ACES.
+ Creates colorspace covering the conversion from ProTune to ACES, with various transfer
+ functions and encoding gamuts covered
Parameters
----------
- parameter : type
- Parameter description.
+ gamut : str
+ The name of the encoding gamut to use.
+ transfer_function : str
+ The name of the transfer function to use
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A ColorSpace container class referencing the LUTs, matrices and identifying
+ information for the requested colorspace.
"""
# The gamut should be marked as experimental until matrices are fully
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for GoPro cameras and encodings
"""
colorspaces = []
lut_resolution_1d,
aliases):
"""
- Object description.
-
- Panasonic V-Log to ACES.
+ Creates colorspace covering the conversion from VLog to ACES, with various transfer
+ functions and encoding gamuts covered
Parameters
----------
- parameter : type
- Parameter description.
+ gamut : str
+ The name of the encoding gamut to use.
+ transfer_function : str
+ The name of the transfer function to use
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A ColorSpace container class referencing the LUTs, matrices and identifying
+ information for the requested colorspace.
"""
name = '%s - %s' % (transfer_function, gamut)
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for Panasonic cameras and encodings
"""
colorspaces = []
lut_resolution_1d,
aliases=None):
"""
- Object description.
-
- RED colorspaces to ACES.
+ Creates colorspace covering the conversion from RED spaces to ACES, with various
+ transfer functions and encoding gamuts covered
Parameters
----------
- parameter : type
- Parameter description.
+ gamut : str
+ The name of the encoding gamut to use.
+ transfer_function : str
+ The name of the transfer function to use
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A ColorSpace container class referencing the LUTs, matrices and identifying
+ information for the requested colorspace.
"""
if aliases is None:
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for RED cameras and encodings
"""
colorspaces = []
lut_resolution_1d,
aliases):
"""
- Object description.
-
- SLog to ACES.
+ Creates colorspace covering the conversion from Sony spaces to ACES, with various
+ transfer functions and encoding gamuts covered
Parameters
----------
- parameter : type
- Parameter description.
+ gamut : str
+ The name of the encoding gamut to use.
+ transfer_function : str
+ The name of the transfer function to use
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ aliases : list of str
+ Aliases for this colorspace
Returns
-------
- type
- Return value description.
+ ColorSpace
+ A ColorSpace container class referencing the LUTs, matrices and identifying
+ information for the requested colorspace.
"""
name = '%s - %s' % (transfer_function, gamut)
Parameters
----------
- parameter : type
- Parameter description.
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
Returns
-------
- type
- Return value description.
+ list
+ A list of colorspaces for Sony cameras and encodings
"""
colorspaces = []
config : Config
*OCIO* configuration.
color_picking : str or unicode, optional
- Color picking role title.
+ Color Picking role title.
color_timing : str or unicode, optional
- Color timing role title.
+ Color Timing role title.
compositing_log : str or unicode, optional
- Compositing log role title.
+ Compositing Log role title.
data : str or unicode, optional
Data role title.
default : str or unicode, optional
Default role title.
matte_paint : str or unicode, optional
- Matte painting role title.
+ Matte Painting role title.
reference : str or unicode, optional
Reference role title.
scene_linear : str or unicode, optional
- Scene linear role title.
+ Scene Linear role title.
texture_paint : str or unicode, optional
- Texture painting role title.
+ Texture Painting role title.
+ rendering : str or unicode, optional
+ Rendering role title.
+ compositing_linear : str or unicode, optional
+ Compositing Linear role title.
Returns
-------
bool
config_data,
multiple_displays=False):
"""
- Object description.
+ Integrates a set of looks into the *OCIO* config's Displays and Views
Parameters
----------
- parameter : type
- Parameter description.
+ looks : array of str or unicode
+ Names of looks
+ reference_name : str or unicode
+ The name of the *OCIO* reference colorspace
+ config_data : dict
+ Colorspaces and transforms converting between those colorspaces and
+ the reference colorspace, *ACES*.
+ multiple_displays : bool
+ If true, looks are added to the config_data looks list
+ If false, looks are integrated directly into the list of displays and
+ views. This may be necessary due to limitations of some applications'
+ currently implementation of OCIO, ex. Maya 2016.
Returns
-------
- type
- Return value description.
+ None
"""
look_names = [look[0] for look in looks]
look_info=None,
custom_lut_dir=None):
"""
- Object description.
+ Create the *OCIO* config based on the configuration data
Parameters
----------
- parameter : type
- Parameter description.
+ config_data : dict
+ Colorspaces and transforms converting between those colorspaces and
+ the reference colorspace, *ACES*, along with other data needed to
+ generate a complete *OCIO* configuration
+ aliases : bool, optional
+ Whether or not to include Alias colorspaces
+ prefix : bool, optional
+ Whether or not to prefix the colorspace names with their Family names
+ multiple_displays : bool, optional
+ Whether to create a single display named *ACES* with Views for each
+ Output Transform or multiple displays, one for each Output Transform
+ look_info : array of str or unicode, optional
+ Paths and names for look data
+ custom_lut_dir : str or unicode, optional
+ Directory to use for storing custom look files
Returns
-------
- type
- Return value description.
+ *OCIO* config
+ The constructed OCIO configuration
"""
if look_info is None:
lut_resolution_3d=64,
cleanup=True):
"""
- Object description.
+ Create the *ACES* LUTs and data structures needed for later *OCIO*
+ configuration generation
Parameters
----------
- parameter : type
- Parameter description.
+ odt_info : array of dicts of str or unicode
+ Descriptions of the *ACES* Output Transforms
+ lmt_info : array of dicts of str or unicode
+ Descriptions of the *ACES* Look Transforms
+ shaper_name : str or unicode
+ The name of the Shaper function to use when generating LUTs.
+ Options: Log2, DolbyPQ
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The path to use when writing LUTs
+ lut_resolution_1d : int, optional
+ The resolution of generated 1D LUTs
+ lut_resolution_3d : int, optional
+ The resolution of generated 3D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
Returns
-------
dict
- Colorspaces and transforms converting between those colorspaces and
- the reference colorspace, *ACES*.
+ Colorspaces, LUT paths and transforms converting between those
+ colorspaces and the reference colorspace, *ACES*.
"""
print('create_config_data - begin')
lut_resolution_shaper=1024,
prefix=False):
"""
- Object description.
+ Generate baked representations of the transforms from the *ACES* *OCIO*
+ configuration
Parameters
----------
- parameter : type
- Parameter description.
+ odt_info : array of dicts of str or unicode
+ Descriptions of the *ACES* Output Transforms
+ shaper_name : str or unicode
+ The name of the Shaper function to use when generating LUTs.
+ Options: Log2, DolbyPQ
+ baked_directory : str or unicode
+ The path to use when writing baked LUTs
+ config_path : str or unicode
+ The path to the *OCIO* configuration
+ lut_resolution_3d : int, optional
+ The resolution of generated 3D LUTs
+ lut_resolution_shaper : int, optional
+ The resolution of shaper used as part of some 3D LUTs
+ prefix : bool, optional
+ Whether or not colorspace names will use their Family names as prefixes
+ in the *OCIO* config
Returns
-------
- type
- Return value description.
+ None
"""
odt_info_C = dict(odt_info)
bake_secondary_luts=False,
custom_lut_dir=None):
"""
- Object description.
+ Create the directories needed for configuration generation
Parameters
----------
- parameter : type
- Parameter description.
+ config_directory : str or unicode
+ The base config directory
+ bake_secondary_luts : bool, optional
+ Whether or not to create directories for baked LUTs
+ custom_lut_dir : bool, optional
+ Whether or not to create directories for custom Look LUTs
Returns
-------
- type
- Return value description.
+ None
"""
lut_directory = os.path.join(config_directory, 'luts')
Parameters
----------
- parameter : type
- Parameter description.
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ config_directory : str or unicode
+ The directory that will hold the generated configuration and LUTs
+ lut_resolution_1d : int, optional
+ The resolution of generated 1D LUTs
+ lut_resolution_3d : int, optional
+ The resolution of generated 3D LUTs
+ bake_secondary_luts : bool, optional
+ Whether or not to create directories for baked LUTs
+ multiple_displays : bool, optional
+ Whether to create a single display named *ACES* with Views for each
+ Output Transform or multiple displays, one for each Output Transform
+ look_info : array of str or unicode, optional
+ Paths and names for look data
+ copy_custom_luts : bool, optional
+ Whether to reference custom look LUTs directly or to copy them into a
+ directory within the generated configuration
+ cleanup : bool, optional
+ Whether or not to clean up the intermediate images
+ prefix_colorspaces_with_family_names : bool, optional
+ Whether or not colorspace names will use their Family names as prefixes
+ in the *OCIO* config
+ shaper_base_name : str or unicode
+ The name of the Shaper function to use when generating LUTs.
+ Options: Log2, DolbyPQ
Returns
-------
- type
- Return value description.
+ bool
+ Success or failure of configuration generation process
"""
if look_info is None:
lut_directory = generate_config_directory(config_directory,
bake_secondary_luts,
custom_lut_dir)
-
odt_info = aces.get_ODTs_info(aces_ctl_directory)
lmt_info = aces.get_LMTs_info(aces_ctl_directory)
def main():
"""
- Object description.
+ A simple main that allows the user to exercise the various functions
+ defined in this file
Parameters
----------
- parameter : type
- Parameter description.
+ None
Returns
-------
- type
- Return value description.
+ None
"""
import optparse
# -*- coding: utf-8 -*-
"""
-Defines objects to generate various kind of 1d, 2d and 3d LUTs in various file
+Defines objects to generate various kind of 1D and 3D LUTs in various file
formats.
"""
min_value=0,
max_value=1):
"""
- Object description.
+ Generates a 1D LUT image, i.e. a simple ramp, going from the min_value to
+ the max_value.
Parameters
----------
- parameter : type
- Parameter description.
+ ramp_1d_path : str or unicode
+ The path of the 1D ramp image to be written
+ resolution : int, optional
+ The resolution of the 1D ramp image to be written
+ min_value : float, optional
+ The lowest value in the 1D ramp
+ max_value : float, optional
+ The highest value in the 1D ramp
Returns
-------
- type
- Return value description.
+ None
"""
ramp = oiio.ImageOutput.create(ramp_1d_path)
channels,
components=3):
"""
- Object description.
+ Writes a 1D LUT in the Sony Pictures Imageworks .spi1d format.
Credit to *Alex Fry* for the original single channel version of the spi1d
writer.
Parameters
----------
- parameter : type
- Parameter description.
+ filename : str or unicode
+ The path of the 1D LUT to be written
+ from_min : float
+ The lowest value in the 1D ramp
+ from_max : float
+ The highest value in the 1D ramp
+ data : array of floats
+ The entries in the LUT
+ entries : int
+ The resolution of the LUT, i.e. number of entries in the data set
+ channels : int
+ The number of channels in the data
+ components : int, optional
+ The number of channels in the data to actually write
Returns
-------
- type
- Return value description.
+ None
"""
# May want to use fewer components than there are channels in the data
channels,
components=3):
"""
- Object description.
+ Writes a 1D LUT in the Rising Sun Research Cinespace .csp format.
Parameters
----------
- parameter : type
- Parameter description.
+ filename : str or unicode
+ The path of the 1D LUT to be written
+ from_min : float
+ The lowest value in the 1D ramp
+ from_max : float
+ The highest value in the 1D ramp
+ data : array of floats
+ The entries in the LUT
+ entries : int
+ The resolution of the LUT, i.e. number of entries in the data set
+ channels : int
+ The number of channels in the data
+ components : int, optional
+ The number of channels in the data to actually write
Returns
-------
- type
- Return value description.
+ None
"""
# May want to use fewer components than there are channels in the data
channels,
components=3):
"""
- Object description.
+ Writes a 1D LUT in the Academy Color Transformation Language .ctl format.
Parameters
----------
- parameter : type
- Parameter description.
+ filename : str or unicode
+ The path of the 1D LUT to be written
+ from_min : float
+ The lowest value in the 1D ramp
+ from_max : float
+ The highest value in the 1D ramp
+ data : array of floats
+ The entries in the LUT
+ entries : int
+ The resolution of the LUT, i.e. number of entries in the data set
+ channels : int
+ The number of channels in the data
+ components : int, optional
+ The number of channels in the data to actually write
Returns
-------
- type
- Return value description.
+ None
"""
# May want to use fewer components than there are channels in the data
lut_components=3,
format='spi1d'):
"""
- Object description.
+ Writes a 1D LUT in the specified format.
Parameters
----------
- parameter : type
- Parameter description.
+ filename : str or unicode
+ The path of the 1D LUT to be written
+ from_min : float
+ The lowest value in the 1D ramp
+ from_max : float
+ The highest value in the 1D ramp
+ data : array of floats
+ The entries in the LUT
+ data_entries : int
+ The resolution of the LUT, i.e. number of entries in the data set
+ data_channels : int
+ The number of channels in the data
+ lut_components : int, optional
+ The number of channels in the data to actually use when writing
+ format : str or unicode, optional
+ The format of the the 1D LUT that will be written
Returns
-------
- type
- Return value description.
+ None
"""
ocio_formats_to_extensions = {'cinespace': 'csp',
channels=3,
format='spi1d'):
"""
- Object description.
+ Reads a 1D LUT image and writes a 1D LUT in the specified format.
Parameters
----------
- parameter : type
- Parameter description.
+ ramp_1d_path : str or unicode
+ The path of the 1D ramp image to be read
+ output_path : str or unicode, optional
+ The path of the 1D LUT to be written
+ min_value : float, optional
+ The lowest value in the 1D ramp
+ max_value : float, optional
+ The highest value in the 1D ramp
+ channels : int, optional
+ The number of channels in the data
+ format : str or unicode, optional
+ The format of the the 1D LUT that will be written
Returns
-------
- type
- Return value description.
+ None
"""
if output_path is None:
def generate_3d_LUT_image(ramp_3d_path, resolution=32):
"""
- Object description.
+ Generates a 3D LUT image covering the specified resolution
+ Relies on OCIO's ociolutimage command
Parameters
----------
- parameter : type
- Parameter description.
+ ramp_3d_path : str or unicode
+ The path of the 3D ramp image to be written
+ resolution : int, optional
+ The resolution of the 3D ramp image to be written
Returns
-------
- type
- Return value description.
+ None
"""
args = ['--generate',
resolution=32,
format='spi3d'):
"""
- Object description.
+ Reads a 3D LUT image and writes a 3D LUT in the specified format.
+ Relies on OCIO's ociolutimage command
Parameters
----------
- parameter : type
- Parameter description.
+ ramp_3d_path : str or unicode
+ The path of the 3D ramp image to be read
+ output_path : str or unicode, optional
+ The path of the 1D LUT to be written
+ resolution : int, optional
+ The resolution of the 3D LUT represented in the image
+ format : str or unicode, optional
+ The format of the the 3D LUT that will be written
Returns
-------
- type
- Return value description.
+ None
"""
if output_path is None:
global_params=None,
aces_ctl_directory=None):
"""
- Object description.
+ Applies a set of Academy Color Transformation Language .ctl files to
+ an input image and writes a new image.
+ Relies on the ACES ctlrender command
Parameters
----------
- parameter : type
- Parameter description.
+ input_image : str or unicode
+ The path to the image to transform using the CTL files
+ output_image : str or unicode
+ The path to write the result of the transforms
+ ctl_paths : array of str or unicode, optional
+ The path to write the result of the transforms
+ input_scale : float, optional
+ The argument to the ctlrender -input_scale parameter
+ For images with integer bit depths, this divides image code values
+ before they are sent to the ctl commands
+ For images with float or half bit depths, this multiplies image code
+ values before they are sent to the ctl commands
+ output_scale : float, optional
+ The argument to the ctlrender -output_scale parameter
+ For images with integer bit depths, this multiplies image code values
+ before they are written to a file.
+ For images with float or half bit depths, this divides image code values
+ before they are sent to the ctl commands
+ global_params : dict of key value pairs, optional
+ The set of parameter names and values to pass to the ctlrender
+ -global_param1 parameter
+ aces_ctl_directory : str or unicode, optional
+ The path to the aces 'transforms/ctl/utilities'
Returns
-------
- type
- Return value description.
+ None
"""
if ctl_paths is None:
def convert_bit_depth(input_image, output_image, depth):
"""
- Object description.
+ Convert the input image to the specified bit depth and write a new image
+ Relies on the OIIO oiiotool command
Parameters
----------
- parameter : type
- Parameter description.
+ input_image : str or unicode
+ The path to the image to transform using the CTL files
+ output_image : str or unicode
+ The path to write the result of the transforms
+ depth : str or unicode
+ The bit depth of the output image
+ Data types include: uint8, sint8, uint10, uint12, uint16, sint16, half, float, double
Returns
-------
- type
- Return value description.
+ None
"""
args = [input_image,
channels=3,
format='spi1d'):
"""
- Object description.
+ Creates a 1D LUT from the specified CTL files by creating a 1D LUT image,
+ applying the CTL files and then extracting and writing a LUT based on the
+ resulting image
Parameters
----------
- parameter : type
- Parameter description.
+ lut_path : str or unicode
+ The path to write the 1D LUT
+ ctl_paths : array of str or unicode
+ The CTL files to apply
+ lut_resolution : int, optional
+ The resolution of the 1D LUT to generate
+ identity_lut_bit_depth : string, optional
+ The bit depth to use for the intermediate 1D LUT image
+ input_scale : float, optional
+ The argument to the ctlrender -input_scale parameter
+ For images with integer bit depths, this divides image code values
+ before they are sent to the ctl commands
+ For images with float or half bit depths, this multiplies image code
+ values before they are sent to the ctl commands
+ output_scale : float, optional
+ The argument to the ctlrender -output_scale parameter
+ For images with integer bit depths, this multiplies image code values
+ before they are written to a file.
+ For images with float or half bit depths, this divides image code values
+ before they are sent to the ctl commands
+ global_params : dict of key, value pairs, optional
+ The set of parameter names and values to pass to the ctlrender
+ -global_param1 parameter
+ cleanup : bool, optional
+ Whether or not to clean up the intermediate images
+ aces_ctl_directory : str or unicode, optional
+ The path to the aces 'transforms/ctl/utilities'
+ min_value : float, optional
+ The minimum value to consider as input to the LUT
+ max_value : float, optional
+ The maximum value to consider as input to the LUT
+ channels : int, optional
+ The number of channels to use for the LUT. 1 or 3 are valid.
+ format : str or unicode, optional
+ The format to use when writing the LUT
Returns
-------
- type
- Return value description.
+ None
"""
if global_params is None:
corrected_lut_image,
lut_resolution):
"""
- Object description.
+ For some combinations of resolution and bit depth, ctlrender would generate
+ images with the right number of pixels but with the values for width and
+ height transposed. This function generating a new, corrected image based on
+ the original. The function acts as a pass through if the problem is not
+ detected.
Parameters
----------
- parameter : type
- Parameter description.
+ transformed_lut_image : str or unicode
+ The path to an image generated by cltrender
+ corrected_lut_image : str or unicode
+ The path to an 'corrected' image to be generated
+ lut_resolution : int
+ The resolution of the 3D LUT that should be contained in
+ transformed_lut_image
Returns
-------
- type
- Return value description.
+ str or unicode
+ The path to the corrected image, or the original, if no correction was
+ needed.
"""
transformed = oiio.ImageInput.open(transformed_lut_image)
aces_ctl_directory=None,
format='spi3d'):
"""
- Object description.
+ Creates a 3D LUT from the specified CTL files by creating a 3D LUT image,
+ applying the CTL files and then extracting and writing a LUT based on the
+ resulting image
Parameters
----------
- parameter : type
- Parameter description.
+ lut_path : str or unicode
+ The path to write the 1D LUT
+ ctl_paths : array of str or unicode
+ The CTL files to apply
+ lut_resolution : int, optional
+ The resolution of the 1D LUT to generate
+ identity_lut_bit_depth : string, optional
+ The bit depth to use for the intermediate 1D LUT image
+ input_scale : float, optional
+ The argument to the ctlrender -input_scale parameter
+ For images with integer bit depths, this divides image code values
+ before they are sent to the ctl commands
+ For images with float or half bit depths, this multiplies image code
+ values before they are sent to the ctl commands
+ output_scale : float, optional
+ The argument to the ctlrender -output_scale parameter
+ For images with integer bit depths, this multiplies image code values
+ before they are written to a file.
+ For images with float or half bit depths, this divides image code values
+ before they are sent to the ctl commands
+ global_params : dict of key, value pairs, optional
+ The set of parameter names and values to pass to the ctlrender
+ -global_param1 parameter
+ cleanup : bool, optional
+ Whether or not to clean up the intermediate images
+ aces_ctl_directory : str or unicode, optional
+ The path to the aces 'transforms/ctl/utilities'
+ format : str or unicode, optional
+ The format to use when writing the LUT
Returns
-------
- type
- Return value description.
+ None
"""
if global_params is None:
def main():
"""
- Object description.
+ A simple main that allows the user to exercise the various functions
+ defined in this file
Parameters
----------
- parameter : type
- Parameter description.
+ None
Returns
-------
- type
- Return value description.
+ None
"""
import optparse
allocation_vars=None,
aces_transform_id=None):
"""
- Object description.
+ Constructor for ColorSpace container class
Parameters
----------
- parameter : type
- Parameter description.
+ name : str or unicode
+ Name of the colorspace
+ All other arguments are optional
Returns
-------
- type
- Return value description.
+ None
"""
if aliases is None:
Parameters
----------
- parameter : type
- Parameter description.
+ mat33 : array of float
+ A 3x3 matrix
Returns
-------
- type
- Return value description.
+ array of float
+ A 4x4 matrix
"""
return [mat33[0], mat33[1], mat33[2], 0,
def filter_words(words, filters_in=None, filters_out=None, flags=0):
"""
- Object description.
+ A function to filter strings in an array
Parameters
----------
- parameter : type
- Parameter description.
+ words : array of str or unicode
+ Array of strings
+ filters_in : array of str or unicode, optional
+ Words to match
+ filters_out : array of str or unicode, optional
+ Words to NOT match
+ flags : int, optional
+ Flags for re.search
Returns
-------
- type
- Return value description.
+ array of str or unicode
+ An array of matched or unmatched strings
"""
filtered_words = []
def files_walker(directory, filters_in=None, filters_out=None, flags=0):
"""
- Object description.
+ A function to walk a directory hierarchy, only returning items that do or
+ do not match the specified filters
Parameters
----------
- parameter : type
- Parameter description.
+ directory : str or unicode
+ The starting point for directory walking
+ filters_in : array of str or unicode, optional
+ File or directory names to match
+ filters_out : array of str or unicode, optional
+ File or directory names to NOT match
+ flags : int, optional
+ Flags for re.search
Returns
-------
- type
- Return value description.
+ iterable
+ The next matching file or directory name
"""
for parent_directory, directories, files in os.walk(
def sanitize(path):
"""
- Object description.
+ Replaces occurrences of ' ', '(', or ')' in the string with an underscore.
Parameters
----------
- parameter : type
- Parameter description.
+ path : str or unicode
+ Path string to manipulate.
Returns
-------
- type
- Return value description.
+ unicode
+ Manipulated string.
"""
return replace(path, {' ': '_', ')': '_', '(': '_'})