Implements support for *ACES* colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import math
import numpy
import os
lut_resolution_1d,
cleanup,
name='ACEScc',
- min_value=0.0,
- max_value=1.0,
- input_scale=1.0):
+ min_value=0,
+ max_value=1,
+ input_scale=1):
"""
Creates the *ACEScc* colorspace.
lut_resolution_1d,
'float',
input_scale,
- 1.0,
+ 1,
{},
cleanup,
aces_ctl_directory,
ctls,
lut_resolution_1d,
'uint16',
- 64.0,
- 1.0,
+ 64,
+ 1,
{},
cleanup,
aces_ctl_directory)
if bit_depth == 10:
cs.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]
+ ADX_to_CDD = [1023 / 500, 0, 0, 0,
+ 0, 1023 / 500, 0, 0,
+ 0, 0, 1023 / 500, 0,
+ 0, 0, 0, 1]
+ offset = [-95 / 500, -95 / 500, -95 / 500, 0]
elif bit_depth == 16:
cs.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]
+ ADX_to_CDD = [65535 / 8000, 0, 0, 0,
+ 0, 65535 / 8000, 0, 0,
+ 0, 0, 65535 / 8000, 0,
+ 0, 0, 0, 1]
+ offset = [-1520 / 8000, -1520 / 8000, -1520 / 8000, 0]
cs.to_reference_transforms = []
'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],
+ 0, 0, 0, 1],
'direction': 'forward'})
# Copied from *Alex Fry*'s *adx_cid_to_rle.py*
-1.121718645000000,
-0.926545676714876]
- REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
- math.log(0.18, 10.0))
+ REF_PT = ((7120 - 1520) / 8000 * (100 / 55) -
+ math.log(0.18, 10))
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
+ return (100 / 55) * x - REF_PT
def fit(value, from_min, from_max, to_min, to_max):
if from_min == from_max:
to_max - to_min) + to_min
num_samples = 2 ** 12
- domain = (-0.19, 3.0)
+ domain = (-0.19, 3)
data = []
for i in xrange(num_samples):
- x = i / (num_samples - 1.0)
- x = fit(x, 0.0, 1.0, domain[0], domain[1])
+ x = i / (num_samples - 1)
+ x = fit(x, 0, 1, domain[0], domain[1])
data.append(cid_to_rle(x))
lut = 'ADX_CID_to_RLE.spi1d'
'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],
+ 0, 0, 0, 1],
'direction': 'forward'})
cs.from_reference_transforms = []
lut_resolution_1d=1024,
lut_resolution_3d=64,
cleanup=True,
- aliases=[]):
+ aliases=None):
"""
Creates the *ACES LMT* colorspace.
*ACES LMT* colorspace.
"""
+ if aliases is None:
+ aliases = []
+
cs = ColorSpace('%s' % lmt_name)
cs.description = 'The ACES Look Transform: %s' % lmt_name
cs.aliases = aliases
ctls,
lut_resolution_1d,
'float',
- 1.0 / shaper_input_scale,
- 1.0,
+ 1 / shaper_input_scale,
+ 1,
shaper_params,
cleanup,
aces_ctl_directory)
ctls,
lut_resolution_3d,
'float',
- 1.0 / shaper_input_scale,
- 1.0,
+ 1 / shaper_input_scale,
+ 1,
shaper_params,
cleanup,
aces_ctl_directory)
ctls,
lut_resolution_3d,
'half',
- 1.0,
+ 1,
shaper_input_scale,
shaper_params,
cleanup,
lut_resolution_1d=1024,
lut_resolution_3d=64,
cleanup=True,
- aliases=[]):
+ aliases=None):
"""
Object description.
Return value description.
"""
+ if aliases is None:
+ aliases = []
+
cs = ColorSpace('%s' % odt_name)
cs.description = '%s - %s Output Transform' % (
odt_values['transformUserNamePrefix'], odt_name)
ctls,
lut_resolution_1d,
'float',
- 1.0 / shaper_input_scale,
- 1.0,
+ 1 / shaper_input_scale,
+ 1,
shaper_params,
cleanup,
aces_ctl_directory)
ctls,
lut_resolution_3d,
'float',
- 1.0 / shaper_input_scale,
- 1.0,
+ 1 / shaper_input_scale,
+ 1,
shaper_params,
cleanup,
aces_ctl_directory)
ctls,
lut_resolution_3d,
'half',
- 1.0,
+ 1,
shaper_input_scale,
shaper_params,
cleanup,
cleanup,
name='log',
aliases=[],
- min_value=0.0,
- max_value=1.0,
- input_scale=1.0,
+ min_value=0,
+ max_value=1,
+ input_scale=1,
middle_grey=0.18,
- min_exposure=-6.0,
+ min_exposure=-6,
max_exposure=6.5):
"""
Creates the *Generic Log* colorspace.
lut_resolution_1d,
'float',
input_scale,
- 1.0,
+ 1,
{'middleGrey': middle_grey,
'minExposure': min_exposure,
'maxExposure': max_exposure},
lmt_shaper_name_aliases = ['crv_lmtshaper']
lmt_params = {
'middleGrey': 0.18,
- 'minExposure': -10.0,
+ 'minExposure': -10,
'maxExposure': 6.5}
lmt_shaper = create_generic_log(aces_ctl_directory,
aliases=lmt_shaper_name_aliases)
colorspaces.append(lmt_shaper)
- shaper_input_scale_generic_log2 = 1.0
+ shaper_input_scale_generic_log2 = 1
# *Log 2* shaper name and *CTL* transforms bundled up.
lmt_shaper_data = [
log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)]
log2_params = {
'middleGrey': 0.18,
- 'minExposure': -6.0,
+ 'minExposure': -6,
'maxExposure': 6.5}
log2_shaper = create_generic_log(
aliases=log2_shaper_name_aliases)
colorspaces.append(log2_shaper)
- shaper_input_scale_generic_log2 = 1.0
+ shaper_input_scale_generic_log2 = 1
# *Log 2* shaper name and *CTL* transforms bundled up.
log2_shaper_data = [
Defines objects creating the *ACES* configuration.
"""
+from __future__ import division
+
import os
import sys
Implements support for *ARRI* colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import array
import math
import os
# Globals.
IDT_maker_version = '0.08'
- nominal_EI = 400.0
+ nominal_EI = 400
black_signal = 0.003907
mid_gray_signal = 0.01
encoding_gain = 0.256598
0.89 - 1) / 3 + 1) * encoding_gain
def log_c_inverse_parameters_for_EI(EI):
- cut = 1.0 / 9.0
- slope = 1.0 / (cut * math.log(10))
+ cut = 1 / 9
+ slope = 1 / (cut * math.log(10))
offset = math.log10(cut) - slope * cut
gain = EI / nominal_EI
gray = mid_gray_signal / gain
enc_gain = gain_for_EI(EI)
enc_offset = encoding_offset
for i in range(0, 3):
- nz = ((95.0 / 1023.0 - enc_offset) / enc_gain - offset) / slope
+ nz = ((95 / 1023 - enc_offset) / enc_gain - offset) / slope
enc_offset = encoding_offset - math.log10(1 + nz) * enc_gain
- a = 1.0 / gray
+ a = 1 / gray
b = nz - black_signal / gray
e = slope * a * enc_gain
f = enc_gain * (slope * b + offset) + enc_offset
p = log_c_inverse_parameters_for_EI(exposure_index)
breakpoint = p['e'] * p['cut'] + p['f']
if code_value > breakpoint:
- linear = ((pow(10, (code_value / 1023.0 - p['d']) / p['c']) -
+ linear = ((pow(10, (code_value / 1023 - p['d']) / p['c']) -
p['b']) / p['a'])
else:
- linear = (code_value / 1023.0 - p['f']) / p['e']
+ linear = (code_value / 1023 - p['f']) / p['e']
return linear
cs.to_reference_transforms = []
if transfer_function == 'V3 LogC':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = log_c_to_linear(1023.0 * c / (lut_resolution_1d - 1),
+ data[c] = log_c_to_linear(1023 * c / (lut_resolution_1d - 1),
int(exposure_index))
lut = '%s_to_linear.spi1d' % (
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
transfer_function = 'V3 LogC'
gamut = 'Wide Gamut'
- # EIs = [160.0, 200.0, 250.0, 320.0, 400.0, 500.0, 640.0, 800.0,
- # 1000.0, 1280.0, 1600.0, 2000.0, 2560.0, 3200.0]
+ # EIs = [160, 200, 250, 320, 400, 500, 640, 800,
+ # 1000, 1280, 1600, 2000, 2560, 3200]
EIs = [160, 200, 250, 320, 400, 500, 640, 800,
1000, 1280, 1600, 2000, 2560, 3200]
default_EI = 800
Implements support for *Canon* colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import array
import os
cs.is_data = False
def legal_to_full(code_value):
- return (code_value - 64.0) / (940.0 - 64.0)
+ return (code_value - 64) / (940 - 64)
def c_log_to_linear(code_value):
# log = fullToLegal(c1 * log10(c2*linear + 1) + c3)
c2 = 10.1596
c3 = 0.0730597
- linear = (pow(10.0, (legal_to_full(code_value) - c3) / c1) - 1.0) / c2
+ linear = (pow(10, (legal_to_full(code_value) - c3) / c1) - 1) / c2
linear *= 0.9
return linear
if transfer_function == 'Canon-Log':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = c_log_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+ data[c] = c_log_to_linear(1023 * c / (lut_resolution_1d - 1))
lut = '%s_to_linear.spi1d' % transfer_function
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
if gamut == 'Rec. 709 Daylight':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.561538969, 0.402060105, 0.036400926, 0.0,
- 0.092739623, 0.924121198, -0.016860821, 0.0,
- 0.084812961, 0.006373835, 0.908813204, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.561538969, 0.402060105, 0.036400926, 0,
+ 0.092739623, 0.924121198, -0.016860821, 0,
+ 0.084812961, 0.006373835, 0.908813204, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
elif gamut == 'Rec. 709 Tungsten':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.566996399, 0.365079418, 0.067924183, 0.0,
- 0.070901044, 0.880331008, 0.048767948, 0.0,
- 0.073013542, -0.066540862, 0.99352732, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.566996399, 0.365079418, 0.067924183, 0,
+ 0.070901044, 0.880331008, 0.048767948, 0,
+ 0.073013542, -0.066540862, 0.99352732, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
elif gamut == 'DCI-P3 Daylight':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.607160575, 0.299507286, 0.093332140, 0.0,
- 0.004968120, 1.050982224, -0.055950343, 0.0,
- -0.007839939, 0.000809127, 1.007030813, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.607160575, 0.299507286, 0.093332140, 0,
+ 0.004968120, 1.050982224, -0.055950343, 0,
+ -0.007839939, 0.000809127, 1.007030813, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
elif gamut == 'DCI-P3 Tungsten':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.650279125, 0.253880169, 0.095840706, 0.0,
- -0.026137986, 1.017900530, 0.008237456, 0.0,
- 0.007757558, -0.063081669, 1.055324110, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.650279125, 0.253880169, 0.095840706, 0,
+ -0.026137986, 1.017900530, 0.008237456, 0,
+ 0.007757558, -0.063081669, 1.055324110, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
elif gamut == 'Cinema Gamut Daylight':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.763064455, 0.149021161, 0.087914384, 0.0,
- 0.003657457, 1.10696038, -0.110617837, 0.0,
- -0.009407794, -0.218383305, 1.227791099, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.763064455, 0.149021161, 0.087914384, 0,
+ 0.003657457, 1.10696038, -0.110617837, 0,
+ -0.009407794, -0.218383305, 1.227791099, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
elif gamut == 'Cinema Gamut Tungsten':
cs.to_reference_transforms.append({
'type': 'matrix',
- 'matrix': [0.817416293, 0.090755698, 0.091828009, 0.0,
- -0.035361374, 1.065690585, -0.030329211, 0.0,
- 0.010390366, -0.299271107, 1.288880741, 0.0,
- 0, 0, 0, 1.0],
+ 'matrix': [0.817416293, 0.090755698, 0.091828009, 0,
+ -0.035361374, 1.065690585, -0.030329211, 0,
+ 0.010390366, -0.299271107, 1.288880741, 0,
+ 0, 0, 0, 1],
'direction': 'forward'})
cs.from_reference_transforms = []
Implements support for general colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import aces_ocio.create_aces_colorspaces as aces
from aces_ocio.utilities import ColorSpace, mat44_from_mat33
Implements support for *RED* colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import array
import os
def cineon_to_linear(code_value):
n_gamma = 0.6
- black_point = 95.0
- white_point = 685.0
+ black_point = 95
+ white_point = 685
code_value_to_density = 0.002
- black_linear = pow(10.0, (black_point - white_point) * (
+ black_linear = pow(10, (black_point - white_point) * (
code_value_to_density / n_gamma))
- code_linear = pow(10.0, (code_value - white_point) * (
+ code_linear = pow(10, (code_value - white_point) * (
code_value_to_density / n_gamma))
- return (code_linear - black_linear) / (1.0 - black_linear)
+ return (code_linear - black_linear) / (1 - black_linear)
cs.to_reference_transforms = []
if transfer_function == 'REDlogFilm':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = cineon_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+ data[c] = cineon_to_linear(1023 * c / (lut_resolution_1d - 1))
lut = 'CineonLog_to_linear.spi1d'
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
Implements support for *Sony* colorspaces conversions and transfer functions.
"""
+from __future__ import division
+
import array
import os
def s_log3_to_linear(code_value):
if code_value >= 171.2102946929:
- linear = (pow(10.0, ((code_value - 420.0) / 261.5)) *
+ linear = (pow(10, ((code_value - 420) / 261.5)) *
(0.18 + 0.01) - 0.01)
else:
- linear = (code_value - 95.0) * 0.01125000 / (171.2102946929 - 95.0)
+ linear = (code_value - 95) * 0.01125000 / (171.2102946929 - 95)
return linear
if transfer_function == 'S-Log1':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = s_log1_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+ data[c] = s_log1_to_linear(1023 * c / (lut_resolution_1d - 1))
lut = '%s_to_linear.spi1d' % transfer_function
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
elif transfer_function == 'S-Log2':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = s_log2_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+ data[c] = s_log2_to_linear(1023 * c / (lut_resolution_1d - 1))
lut = '%s_to_linear.spi1d' % transfer_function
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
elif transfer_function == 'S-Log3':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
- data[c] = s_log3_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+ data[c] = s_log3_to_linear(1023 * c / (lut_resolution_1d - 1))
lut = '%s_to_linear.spi1d' % transfer_function
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
- 0.0,
- 1.0,
+ 0,
+ 1,
data,
lut_resolution_1d,
1)
formats.
"""
+from __future__ import division
+
import array
import os
import sys
def generate_1d_LUT_image(ramp_1d_path,
resolution=1024,
- min_value=0.0,
- max_value=1.0):
+ min_value=0,
+ max_value=1):
"""
Object description.
def generate_1d_LUT_from_image(ramp_1d_path,
output_path=None,
- min_value=0.0,
- max_value=1.0):
+ min_value=0,
+ max_value=1):
"""
Object description.
def apply_CTL_to_image(input_image,
output_image,
ctl_paths=None,
- input_scale=1.0,
- output_scale=1.0,
+ input_scale=1,
+ output_scale=1,
global_params=None,
aces_ctl_directory=None):
"""
ctl_paths,
lut_resolution=1024,
identity_LUT_bit_depth='half',
- input_scale=1.0,
- output_scale=1.0,
+ input_scale=1,
+ output_scale=1,
global_params=None,
cleanup=True,
aces_ctl_directory=None,
- min_value=0.0,
- max_value=1.0):
+ min_value=0,
+ max_value=1):
"""
Object description.
ctl_paths,
lut_resolution=64,
identity_LUT_bit_depth='half',
- input_scale=1.0,
- output_scale=1.0,
+ input_scale=1,
+ output_scale=1,
global_params=None,
cleanup=True,
aces_ctl_directory=None):
p.add_option('--ctlReleasePath', '-r', type='string', default='')
p.add_option('--bitDepth', '-b', type='string', default='float')
p.add_option('--keepTempImages', '', action='store_true')
- p.add_option('--minValue', '', type='float', default=0.0)
- p.add_option('--maxValue', '', type='float', default=1.0)
- p.add_option('--inputScale', '', type='float', default=1.0)
- p.add_option('--outputScale', '', type='float', default=1.0)
+ p.add_option('--minValue', '', type='float', default=0)
+ p.add_option('--maxValue', '', type='float', default=1)
+ p.add_option('--inputScale', '', type='float', default=1)
+ p.add_option('--outputScale', '', type='float', default=1)
p.add_option('--ctlRenderParam', '-p', type='string', nargs=2,
action='append')
a process or a list of other process wrappers which carry such data.\r
"""\r
\r
+from __future__ import division\r
+\r
import os\r
import sys\r
import traceback\r
Defines unit tests for *ACES* configuration.
"""
+from __future__ import division
+
import hashlib
import os
import re
Defines various package utilities objects.
"""
+from __future__ import division
+
import os
import re
from collections import OrderedDict
to_reference_transforms=[],
from_reference_transforms=[],
allocation_type=OCIO.Constants.ALLOCATION_UNIFORM,
- allocation_vars=[0.0, 1.0]):
+ allocation_vars=[0, 1]):
"""
Object description.
Return value description.
"""
- return [mat33[0], mat33[1], mat33[2], 0.0,
- mat33[3], mat33[4], mat33[5], 0.0,
- mat33[6], mat33[7], mat33[8], 0.0,
- 0, 0, 0, 1.0]
+ return [mat33[0], mat33[1], mat33[2], 0,
+ mat33[3], mat33[4], mat33[5], 0,
+ mat33[6], mat33[7], mat33[8], 0,
+ 0, 0, 0, 1]
def filter_words(words, filters_in=None, filters_out=None, flags=0):
Creates the *ACES* configuration.
"""
+from __future__ import division
+
import os
import sys
Tests the *ACES* configuration.
"""
+from __future__ import division
+
import os
import unittest
import sys