'float',
input_scale,
1,
- {'transferFunctionOnly':1},
+ {'transferFunctionOnly': 1},
cleanup,
aces_ctl_directory,
min_value,
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')]
+ # 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_linear.spi1d' % name
lut = sanitize(lut)
cs.from_reference_transforms = []
return cs
+
# -------------------------------------------------------------------------
# *Generic Log Transform*
# -------------------------------------------------------------------------
cs.from_reference_transforms = []
return cs
+
# -------------------------------------------------------------------------
# *base Dolby PQ Transform*
# -------------------------------------------------------------------------
def create_dolbypq(aces_CTL_directory,
- lut_directory,
- lut_resolution_1d,
- cleanup,
- name='pq',
- aliases=[],
- min_value=0.0,
- max_value=1.0,
- input_scale=1.0):
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ name='pq',
+ aliases=[],
+ min_value=0.0,
+ max_value=1.0,
+ input_scale=1.0):
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.is_data = False
ctls = [os.path.join(
- aces_CTL_directory,
- 'utilities',
- 'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')]
+ aces_CTL_directory,
+ 'utilities',
+ 'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name
lut = sanitize(lut)
cs.from_reference_transforms = []
return cs
+
# -------------------------------------------------------------------------
# *Dolby PQ Transform that considers a fixed linear range*
# -------------------------------------------------------------------------
def create_dolbypq_scaled(aces_CTL_directory,
- lut_directory,
- lut_resolution_1d,
- cleanup,
- name='pq',
- aliases=[],
- min_value=0.0,
- max_value=1.0,
- input_scale=1.0,
- middle_grey=0.18,
- min_exposure=-6.0,
- max_exposure=6.5):
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ name='pq',
+ aliases=[],
+ min_value=0.0,
+ max_value=1.0,
+ input_scale=1.0,
+ middle_grey=0.18,
+ min_exposure=-6.0,
+ max_exposure=6.5):
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.is_data = False
ctls = [os.path.join(
- aces_CTL_directory,
- 'utilities',
- 'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl')]
+ aces_CTL_directory,
+ 'utilities',
+ 'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name
lut = sanitize(lut)
cs.from_reference_transforms = []
return cs
+
# -------------------------------------------------------------------------
# *Individual LMT*
# -------------------------------------------------------------------------
return cs
+
# -------------------------------------------------------------------------
# *LMTs*
# -------------------------------------------------------------------------
return colorspaces
+
# -------------------------------------------------------------------------
# *ACES RRT* with supplied *ODT*.
# -------------------------------------------------------------------------
return cs
+
# -------------------------------------------------------------------------
# *ODTs*
# -------------------------------------------------------------------------
log2_shaper_copy_colorspace.equality_group = log2_shaper_copy_name
log2_shaper_copy_colorspace.family = log2_shaper_colorspace.family
log2_shaper_copy_colorspace.is_data = log2_shaper_colorspace.is_data
- log2_shaper_copy_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms)
- log2_shaper_copy_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms)
+ log2_shaper_copy_colorspace.to_reference_transforms = list(
+ log2_shaper_colorspace.to_reference_transforms)
+ log2_shaper_copy_colorspace.from_reference_transforms = list(
+ log2_shaper_colorspace.from_reference_transforms)
colorspaces.append(log2_shaper_copy_colorspace)
# Defining the *Log2 shaper that includes the AP1* primaries.
log2_shaper_api1_name = "%s - AP1" % "Log2 Shaper"
log2_shaper_api1_colorspace = ColorSpace(log2_shaper_api1_name)
log2_shaper_api1_colorspace.description = 'The %s color space' % log2_shaper_api1_name
- log2_shaper_api1_colorspace.aliases = ["%s_ap1" % compact(log2_shaper_copy_name)]
+ log2_shaper_api1_colorspace.aliases = [
+ "%s_ap1" % compact(log2_shaper_copy_name)]
log2_shaper_api1_colorspace.equality_group = log2_shaper_api1_name
log2_shaper_api1_colorspace.family = log2_shaper_colorspace.family
log2_shaper_api1_colorspace.is_data = log2_shaper_colorspace.is_data
- log2_shaper_api1_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms)
- log2_shaper_api1_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms)
+ log2_shaper_api1_colorspace.to_reference_transforms = list(
+ log2_shaper_colorspace.to_reference_transforms)
+ log2_shaper_api1_colorspace.from_reference_transforms = list(
+ log2_shaper_colorspace.from_reference_transforms)
# *AP1* primaries to *AP0* primaries.
log2_shaper_api1_colorspace.to_reference_transforms.append({
shaper_api1_colorspace.equality_group = shaper_api1_name
shaper_api1_colorspace.family = log2_shaper_colorspace.family
shaper_api1_colorspace.is_data = log2_shaper_colorspace.is_data
- shaper_api1_colorspace.to_reference_transforms = list(log2_shaper_api1_colorspace.to_reference_transforms)
- shaper_api1_colorspace.from_reference_transforms = list(log2_shaper_api1_colorspace.from_reference_transforms)
+ shaper_api1_colorspace.to_reference_transforms = list(
+ log2_shaper_api1_colorspace.to_reference_transforms)
+ shaper_api1_colorspace.from_reference_transforms = list(
+ log2_shaper_api1_colorspace.from_reference_transforms)
colorspaces.append(shaper_api1_colorspace)
# Define the base *Dolby PQ Shaper*
# Pick a specific shaper
#
rrt_shaper = log2_shaper_data
- #rrt_shaper = dolbypq_scaled_shaper_data
+ # rrt_shaper = dolbypq_scaled_shaper_data
# *RRT + ODT* combinations.
sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
ACES = create_ACES()
ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
- lut_resolution_1d, cleanup,
+ lut_resolution_1d, cleanup,
min_value=-0.35840, max_value=1.468)
colorspaces.append(ACEScc)
ACEScc)
colorspaces.extend(odts)
- roles = {'color_picking' : ACEScg.name,
- 'color_timing' : ACEScc.name,
- 'compositing_log' : ACEScc.name,
- 'data' : '',
- 'default' : ACES.name,
- 'matte_paint' : ACEScc.name,
- 'reference' : '',
- 'scene_linear' : ACES.name,
- 'texture_paint' : ''}
-
+ roles = {'color_picking': ACEScg.name,
+ 'color_timing': ACEScc.name,
+ 'compositing_log': ACEScc.name,
+ 'data': '',
+ 'default': ACES.name,
+ 'matte_paint': ACEScc.name,
+ 'reference': '',
+ 'scene_linear': ACES.name,
+ 'texture_paint': ''}
return ACES, colorspaces, displays, ACEScc, roles
views.append(display)
# Works with Nuke Studio and Mari, but not Nuke
- #display_name = 'Utility'
+ # display_name = 'Utility'
#displays.append(display_name)
-
+
linear_display_space_name = config_data['linearDisplaySpace'].name
log_display_space_name = config_data['logDisplaySpace'].name
return cs
+
def create_colorspaces(lut_directory,
lut_resolution_1d,
lut_resolution_3d):
return colorspaces
+
def create_raw():
# *Raw* utility space
name = "Raw"
if gamut == 'Protune Gamut':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [ 0.533448429, 0.32413911, 0.142412421, 0,
- -0.050729924, 1.07572006, -0.024990416, 0,
- 0.071419661, -0.290521962, 1.219102381, 0,
+ 'matrix': [0.533448429, 0.32413911, 0.142412421, 0,
+ -0.050729924, 1.07572006, -0.024990416, 0,
+ 0.071419661, -0.290521962, 1.219102381, 0,
0, 0, 0, 1],
'direction': 'forward'})
if (x <= cutInv):
return (x - 0.125) / 5.6
else:
- return pow(10, (x-d)/c) - b
+ return pow(10, (x - d) / c) - b
cs.to_reference_transforms = []
if gamut == 'V-Gamut':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [ 0.724382758, 0.166748484, 0.108497411, 0.0,
- 0.021354009, 0.985138372, -0.006319092, 0.0,
- -0.009234278, -0.00104295, 1.010272625, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.724382758, 0.166748484, 0.108497411, 0.0,
+ 0.021354009, 0.985138372, -0.006319092, 0.0,
+ -0.009234278, -0.00104295, 1.010272625, 0.0,
+ 0, 0, 0, 1.0],
'direction': 'forward'})
cs.from_reference_transforms = []
ramp.close()
-def write_SPI_1d(filename,
- from_min,
- from_max,
- data,
- entries,
- channels,
+def write_SPI_1d(filename,
+ from_min,
+ from_max,
+ data,
+ entries,
+ channels,
components=3):
"""
Object description.
fp.write('}\n')
-def write_CSP_1d(filename,
- from_min,
- from_max,
- data,
- entries,
- channels,
+def write_CSP_1d(filename,
+ from_min,
+ from_max,
+ data,
+ entries,
+ channels,
components=3):
"""
Object description.
fp.write('%d\n' % entries)
if components == 1:
- for i in range(0, entries):
- entry = ''
- for j in range(3):
- entry = '%s %s' % (entry, data[i * channels])
- fp.write('%s\n' % entry)
+ for i in range(0, entries):
+ entry = ''
+ for j in range(3):
+ entry = '%s %s' % (entry, data[i * channels])
+ fp.write('%s\n' % entry)
else:
- for i in range(entries):
- entry = ''
- for j in range(components):
- entry = '%s %s' % (entry, data[i * channels + j])
- fp.write('%s\n' % entry)
+ for i in range(entries):
+ entry = ''
+ for j in range(components):
+ entry = '%s %s' % (entry, data[i * channels + j])
+ fp.write('%s\n' % entry)
fp.write('\n')
-def write_CTL_1d(filename,
- from_min,
- from_max,
- data,
- entries,
- channels,
+
+def write_CTL_1d(filename,
+ from_min,
+ from_max,
+ data,
+ entries,
+ channels,
components=3):
"""
Object description.
with open(filename, 'w') as fp:
fp.write('// %d x %d LUT generated by "generate_lut"\n' % (
- entries, components))
+ entries, components))
fp.write('\n')
fp.write('const float min1d = %3.9f;\n' % from_min)
fp.write('const float max1d = %3.9f;\n' % from_max)
# Write LUT
if components == 1:
- fp.write('const float lut[] = {\n')
- for i in range(0, entries):
- fp.write('%s' % data[i * channels])
- if i != (entries-1):
- fp.write(',')
- fp.write('\n')
- fp.write('};\n')
- fp.write('\n')
- else:
- for j in range(components):
- fp.write('const float lut%d[] = {\n' % j)
+ fp.write('const float lut[] = {\n')
for i in range(0, entries):
fp.write('%s' % data[i * channels])
- if i != (entries-1):
- fp.write(',')
+ if i != (entries - 1):
+ fp.write(',')
fp.write('\n')
fp.write('};\n')
fp.write('\n')
+ else:
+ for j in range(components):
+ fp.write('const float lut%d[] = {\n' % j)
+ for i in range(0, entries):
+ fp.write('%s' % data[i * channels])
+ if i != (entries - 1):
+ fp.write(',')
+ fp.write('\n')
+ fp.write('};\n')
+ fp.write('\n')
fp.write('void main\n')
fp.write('(\n')
fp.write('\n')
fp.write(' // Apply LUT\n')
if components == 1:
- fp.write(' r = lookup1D(lut, min1d, max1d, r);\n')
- fp.write(' g = lookup1D(lut, min1d, max1d, g);\n')
- fp.write(' b = lookup1D(lut, min1d, max1d, b);\n')
+ fp.write(' r = lookup1D(lut, min1d, max1d, r);\n')
+ fp.write(' g = lookup1D(lut, min1d, max1d, g);\n')
+ fp.write(' b = lookup1D(lut, min1d, max1d, b);\n')
elif components == 3:
- fp.write(' r = lookup1D(lut0, min1d, max1d, r);\n')
- fp.write(' g = lookup1D(lut1, min1d, max1d, g);\n')
- fp.write(' b = lookup1D(lut2, min1d, max1d, b);\n')
+ fp.write(' r = lookup1D(lut0, min1d, max1d, r);\n')
+ fp.write(' g = lookup1D(lut1, min1d, max1d, g);\n')
+ fp.write(' b = lookup1D(lut2, min1d, max1d, b);\n')
fp.write('\n')
fp.write(' rOut = r;\n')
fp.write(' gOut = g;\n')
fp.write(' aOut = aIn;\n')
fp.write('}\n')
-def write_1d(filename,
- from_min,
- from_max,
- data,
- data_entries,
- data_channels,
+
+def write_1d(filename,
+ from_min,
+ from_max,
+ data,
+ data_entries,
+ data_channels,
lut_components=3,
format='spi1d'):
"""
Return value description.
"""
- ocioFormatsToExtensions = {'cinespace' : 'csp',
- 'flame' : '3dl',
- 'icc' : 'icc',
- 'houdini' : 'lut',
- 'lustre' : '3dl',
- 'ctl' : 'ctl'}
+ ocioFormatsToExtensions = {'cinespace': 'csp',
+ 'flame': '3dl',
+ 'icc': 'icc',
+ 'houdini': 'lut',
+ 'lustre': '3dl',
+ 'ctl': 'ctl'}
if format in ocioFormatsToExtensions:
- if ocioFormatsToExtensions[format] == 'csp':
- write_CSP_1d(filename,
- from_min,
- from_max,
- data,
- data_entries,
- data_channels,
- lut_components)
- elif ocioFormatsToExtensions[format] == 'ctl':
- write_CTL_1d(filename,
+ if ocioFormatsToExtensions[format] == 'csp':
+ write_CSP_1d(filename,
+ from_min,
+ from_max,
+ data,
+ data_entries,
+ data_channels,
+ lut_components)
+ elif ocioFormatsToExtensions[format] == 'ctl':
+ write_CTL_1d(filename,
+ from_min,
+ from_max,
+ data,
+ data_entries,
+ data_channels,
+ lut_components)
+ else:
+ write_SPI_1d(filename,
from_min,
from_max,
data,
data_entries,
data_channels,
lut_components)
- else:
- write_SPI_1d(filename,
- from_min,
- from_max,
- data,
- data_entries,
- data_channels,
- lut_components)
+
def generate_1d_LUT_from_image(ramp_1d_path,
output_path=None,
type = oiio.FLOAT
ramp_data = ramp.read_image(type)
- write_1d(output_path, min_value, max_value,
- ramp_data, ramp_width, ramp_channels, channels, format)
+ write_1d(output_path, min_value, max_value,
+ ramp_data, ramp_width, ramp_channels, channels, format)
def generate_3d_LUT_image(ramp_3d_path, resolution=32):
lut_extract.execute()
-def generate_3d_LUT_from_image(ramp_3d_path,
- output_path=None,
+def generate_3d_LUT_from_image(ramp_3d_path,
+ output_path=None,
resolution=32,
format='spi3d'):
"""
if output_path is None:
output_path = '%s.%s' % (ramp_3d_path, 'spi3d')
- ocioFormatsToExtensions = {'cinespace' : 'csp',
- 'flame' : '3dl',
- 'icc' : 'icc',
- 'houdini' : 'lut',
- 'lustre' : '3dl'}
+ ocioFormatsToExtensions = {'cinespace': 'csp',
+ 'flame': '3dl',
+ 'icc': 'icc',
+ 'houdini': 'lut',
+ 'lustre': '3dl'}
if format == 'spi3d' or not (format in ocioFormatsToExtensions):
- # Extract a spi3d LUT
- args = ['--extract',
- '--cubesize',
- str(resolution),
- '--maxwidth',
- str(resolution * resolution),
- '--input',
- ramp_3d_path,
- '--output',
- output_path]
- lut_extract = Process(description='extract a 3d LUT',
- cmd='ociolutimage',
- args=args)
- lut_extract.execute()
+ # Extract a spi3d LUT
+ args = ['--extract',
+ '--cubesize',
+ str(resolution),
+ '--maxwidth',
+ str(resolution * resolution),
+ '--input',
+ ramp_3d_path,
+ '--output',
+ output_path]
+ lut_extract = Process(description='extract a 3d LUT',
+ cmd='ociolutimage',
+ args=args)
+ lut_extract.execute()
else:
- output_path_spi3d = '%s.%s' % (output_path, 'spi3d')
-
- # Extract a spi3d LUT
- args = ['--extract',
- '--cubesize',
- str(resolution),
- '--maxwidth',
- str(resolution * resolution),
- '--input',
- ramp_3d_path,
- '--output',
- output_path_spi3d]
- lut_extract = Process(description='extract a 3d LUT',
- cmd='ociolutimage',
- args=args)
- lut_extract.execute()
-
- # Convert to a different format
- args = ['--lut',
- output_path_spi3d,
- '--format',
- format,
- output_path]
- lut_convert = Process(description='convert a 3d LUT',
- cmd='ociobakelut',
- args=args)
- lut_convert.execute()
+ output_path_spi3d = '%s.%s' % (output_path, 'spi3d')
+
+ # Extract a spi3d LUT
+ args = ['--extract',
+ '--cubesize',
+ str(resolution),
+ '--maxwidth',
+ str(resolution * resolution),
+ '--input',
+ ramp_3d_path,
+ '--output',
+ output_path_spi3d]
+ lut_extract = Process(description='extract a 3d LUT',
+ cmd='ociolutimage',
+ args=args)
+ lut_extract.execute()
+
+ # Convert to a different format
+ args = ['--lut',
+ output_path_spi3d,
+ '--format',
+ format,
+ output_path]
+ lut_convert = Process(description='convert a 3d LUT',
+ cmd='ociobakelut',
+ args=args)
+ lut_convert.execute()
def apply_CTL_to_image(input_image,
corrected_LUT_image,
lut_resolution)
- generate_3d_LUT_from_image(corrected_LUT_image,
- lut_path,
- lut_resolution,
+ generate_3d_LUT_from_image(corrected_LUT_image,
+ lut_path,
+ lut_resolution,
format)
if cleanup:
lut_path_spi3d = '%s.%s' % (lut_path, 'spi3d')
os.remove(lut_path_spi3d)
+
def main():
"""
Object description.