- # Matrix converting ACES AP1 primaries to AP0
- ACES_AP1_to_AP0 = [0.6954522414, 0.1406786965, 0.1638690622,
- 0.0447945634, 0.8596711185, 0.0955343182,
- -0.0055258826, 0.0040252103, 1.0015006723]
-
- # Matrix converting ACES AP0 primaries to XYZ
- ACES_AP0_to_XYZ = [0.9525523959, 0.0000000000, 0.0000936786,
- 0.3439664498, 0.7281660966, -0.0721325464,
- 0.0000000000, 0.0000000000, 1.0088251844]
-
- #
- # ACEScc
- #
- def create_ACEScc(name='ACEScc',
- min_value=0.0,
- max_value=1.0,
- input_scale=1.0):
- cs = ColorSpace(name)
- cs.description = 'The %s color space' % name
- cs.equality_group = ''
- cs.family = 'ACES'
- cs.is_data = False
-
- ctls = [os.path.join(aces_CTL_directory,
- 'ACEScc',
- 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl'),
- # This transform gets back to the AP1 primaries
- # Useful as the 1d LUT is only covering the transfer function
- # The primaries switch is covered by the matrix below
- os.path.join(aces_CTL_directory,
- 'ACEScg',
- 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
- lut = '%s_to_ACES.spi1d' % name
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- generate_1d_LUT_from_CTL(
- os.path.join(lut_directory, lut),
- ctls,
- lut_resolution_1d,
- 'float',
- input_scale,
- 1.0,
- {},
- cleanup,
- aces_CTL_directory,
- min_value,
- max_value)
-
- cs.to_reference_transforms = []
- cs.to_reference_transforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # AP1 primaries to AP0 primaries
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': mat44_from_mat33(ACES_AP1_to_AP0),
- 'direction': 'forward'
- })
-
- cs.from_reference_transforms = []
- return cs
-
- ACEScc = create_ACEScc()
- config_data['colorSpaces'].append(ACEScc)
-
- #
- # ACESproxy
- #
- def create_ACESproxy(name='ACESproxy'):
- cs = ColorSpace(name)
- cs.description = 'The %s color space' % name
- cs.equality_group = ''
- cs.family = 'ACES'
- cs.is_data = False
-
- ctls = [
- os.path.join(aces_CTL_directory,
- 'ACESproxy',
- 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
- # This transform gets back to the AP1 primaries
- # Useful as the 1d LUT is only covering the transfer function
- # The primaries switch is covered by the matrix below
- os.path.join(aces_CTL_directory,
- 'ACEScg',
- 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
- lut = '%s_to_aces.spi1d' % name
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- generate_1d_LUT_from_CTL(
- os.path.join(lut_directory, lut),
- ctls,
- lut_resolution_1d,
- 'uint16',
- 64.0,
- 1.0,
- {},
- cleanup,
- aces_CTL_directory)
-
- cs.to_reference_transforms = []
- cs.to_reference_transforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # AP1 primaries to AP0 primaries
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': mat44_from_mat33(ACES_AP1_to_AP0),
- 'direction': 'forward'
- })
-
- cs.from_reference_transforms = []
- return cs
-
- ACESproxy = create_ACESproxy()
- config_data['colorSpaces'].append(ACESproxy)
-
- #
- # ACEScg
- #
- def create_ACEScg(name='ACEScg'):
- cs = ColorSpace(name)
- cs.description = 'The %s color space' % name
- cs.equality_group = ''
- cs.family = 'ACES'
- cs.is_data = False
-
- cs.to_reference_transforms = []
-
- # AP1 primaries to AP0 primaries
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': mat44_from_mat33(ACES_AP1_to_AP0),
- 'direction': 'forward'
- })
-
- cs.from_reference_transforms = []
- return cs
-
- ACEScg = create_ACEScg()
- config_data['colorSpaces'].append(ACEScg)
-
- #
- # ADX
- #
- def create_ADX(bit_depth=10, name='ADX'):
- name = '%s%s' % (name, bit_depth)
- cs = ColorSpace(name)
- cs.description = '%s color space - used for film scans' % name
- cs.equality_group = ''
- cs.family = 'ADX'
- cs.is_data = False
-
- if bit_depth == 10:
- cs.bit_depth = bit_depth = ocio.Constants.BIT_DEPTH_UINT10
- adx_to_cdd = [1023.0 / 500.0, 0.0, 0.0, 0.0,
- 0.0, 1023.0 / 500.0, 0.0, 0.0,
- 0.0, 0.0, 1023.0 / 500.0, 0.0,
- 0.0, 0.0, 0.0, 1.0]
- offset = [-95.0 / 500.0, -95.0 / 500.0, -95.0 / 500.0, 0.0]
- elif bit_depth == 16:
- cs.bit_depth = bit_depth = ocio.Constants.BIT_DEPTH_UINT16
- adx_to_cdd = [65535.0 / 8000.0, 0.0, 0.0, 0.0,
- 0.0, 65535.0 / 8000.0, 0.0, 0.0,
- 0.0, 0.0, 65535.0 / 8000.0, 0.0,
- 0.0, 0.0, 0.0, 1.0]
- offset = [-1520.0 / 8000.0, -1520.0 / 8000.0, -1520.0 / 8000.0,
- 0.0]
-
- cs.to_reference_transforms = []
-
- # Convert from ADX to Channel-Dependent Density
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': adx_to_cdd,
- 'offset': offset,
- 'direction': 'forward'
- })
-
- # Convert from Channel-Dependent Density to Channel-Independent Density
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': [0.75573, 0.22197, 0.02230, 0,
- 0.05901, 0.96928, -0.02829, 0,
- 0.16134, 0.07406, 0.76460, 0,
- 0.0, 0.0, 0.0, 1.0],
- 'direction': 'forward'
- })
-
- # Copied from Alex Fry's adx_cid_to_rle.py
- def create_CID_to_RLE_LUT():
- def interpolate_1D(x, xp, fp):
- return numpy.interp(x, xp, fp)
-
- LUT_1D_xp = [-0.190000000000000,
- 0.010000000000000,
- 0.028000000000000,
- 0.054000000000000,
- 0.095000000000000,
- 0.145000000000000,
- 0.220000000000000,
- 0.300000000000000,
- 0.400000000000000,
- 0.500000000000000,
- 0.600000000000000]
-
- LUT_1D_fp = [-6.000000000000000,
- -2.721718645000000,
- -2.521718645000000,
- -2.321718645000000,
- -2.121718645000000,
- -1.921718645000000,
- -1.721718645000000,
- -1.521718645000000,
- -1.321718645000000,
- -1.121718645000000,
- -0.926545676714876]
-
- REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
- math.log(0.18, 10.0))
-
- def cid_to_rle(x):
- if x <= 0.6:
- return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp)
- return (100.0 / 55.0) * x - REF_PT
-
- def fit(value, from_min, from_max, to_min, to_max):
- if from_min == from_max:
- raise ValueError('from_min == from_max')
- return (value - from_min) / (from_max - from_min) * (
- to_max - to_min) + to_min
-
- NUM_SAMPLES = 2 ** 12
- RANGE = (-0.19, 3.0)
- data = []
- for i in xrange(NUM_SAMPLES):
- x = i / (NUM_SAMPLES - 1.0)
- x = fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
- data.append(cid_to_rle(x))
-
- lut = 'ADX_CID_to_RLE.spi1d'
- write_SPI_1d(os.path.join(lut_directory, lut),
- RANGE[0],
- RANGE[1],
- data,
- NUM_SAMPLES, 1)
-
- return lut
-
- # Convert Channel Independent Density values to Relative Log Exposure
- # values.
- lut = create_CID_to_RLE_LUT()
- cs.to_reference_transforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # Convert Relative Log Exposure values to Relative Exposure values
- cs.to_reference_transforms.append({
- 'type': 'log',
- 'base': 10,
- 'direction': 'inverse'
- })
-
- # Convert Relative Exposure values to ACES values
- cs.to_reference_transforms.append({
- 'type': 'matrix',
- 'matrix': [0.72286, 0.12630, 0.15084, 0,
- 0.11923, 0.76418, 0.11659, 0,
- 0.01427, 0.08213, 0.90359, 0,
- 0.0, 0.0, 0.0, 1.0],
- 'direction': 'forward'
- })
-
- cs.from_reference_transforms = []
- return cs
-
- ADX10 = create_ADX(bit_depth=10)
- config_data['colorSpaces'].append(ADX10)
-
- ADX16 = create_ADX(bit_depth=16)
- config_data['colorSpaces'].append(ADX16)
-
- #
- # Camera Input Transforms
- #
-
- # RED color spaces to ACES
- red_colorspaces = red.create_colorspaces(lut_directory, lut_resolution_1d)
- for cs in red_colorspaces: