本文整理汇总了Python中aces_ocio.utilities.ColorSpace.to_reference_transforms方法的典型用法代码示例。如果您正苦于以下问题:Python ColorSpace.to_reference_transforms方法的具体用法?Python ColorSpace.to_reference_transforms怎么用?Python ColorSpace.to_reference_transforms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aces_ocio.utilities.ColorSpace
的用法示例。
在下文中一共展示了ColorSpace.to_reference_transforms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_transfer_colorspace
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_transfer_colorspace(name='transfer',
transfer_function_name='transfer_function',
transfer_function=lambda x: x,
lut_directory='/tmp',
lut_resolution_1d=1024,
aliases=[]):
"""
Object description.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
type
Return value description.
"""
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.equality_group = name
cs.family = 'Utility'
cs.is_data = False
# A linear space needs allocation variables
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
# Sample the transfer function
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = transfer_function(c / (lut_resolution_1d - 1))
# Write the sampled data to a LUT
lut = '%s_to_linear.spi1d' % transfer_function_name
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
0,
1,
data,
lut_resolution_1d,
1)
# Create the 'to_reference' transforms
cs.to_reference_transforms = []
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'linear',
'direction': 'forward'})
# Create the 'from_reference' transforms
cs.from_reference_transforms = []
return cs
示例2: create_matrix_colorspace
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_matrix_colorspace(name='matrix',
from_reference_values=None,
to_reference_values=None,
aliases=None):
"""
Object description.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
type
Return value description.
"""
if from_reference_values is None:
from_reference_values = []
if to_reference_values is None:
to_reference_values = []
if aliases is None:
aliases = []
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.equality_group = name
cs.family = 'Utility'
cs.is_data = False
# A linear space needs allocation variables.
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
cs.to_reference_transforms = []
if to_reference_values:
for matrix in to_reference_values:
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(matrix),
'direction': 'forward'})
cs.from_reference_transforms = []
if from_reference_values:
for matrix in from_reference_values:
cs.from_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(matrix),
'direction': 'forward'})
return cs
示例3: create_Dolby_PQ_scaled
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_Dolby_PQ_scaled(aces_ctl_directory,
lut_directory,
lut_resolution_1d,
cleanup,
name='pq',
aliases=None,
min_value=0.0,
max_value=1.0,
input_scale=1.0,
middle_grey=0.18,
min_exposure=-6.0,
max_exposure=6.5):
if aliases is None:
aliases = []
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.equality_group = name
cs.family = 'Utility'
cs.is_data = False
ctls = [os.path.join(
aces_ctl_directory,
'utilities',
'ACESlib.OCIOShaper_to_lin_param.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name
lut = sanitize(lut)
generate_1d_LUT_from_CTL(
os.path.join(lut_directory, lut),
ctls,
lut_resolution_1d,
'float',
input_scale,
1.0,
{'middleGrey': middle_grey,
'minExposure': min_exposure,
'maxExposure': max_exposure},
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'})
cs.from_reference_transforms = []
return cs
示例4: create_dolbypq_scaled
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
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,
):
cs = ColorSpace(name)
cs.description = "The %s color space" % name
cs.aliases = aliases
cs.equality_group = name
cs.family = "Utility"
cs.is_data = False
ctls = [os.path.join(aces_CTL_directory, "utilities", "ACESlib.DolbyPQ_to_lin_param.a1.0.0.ctl")]
lut = "%s_to_linear.spi1d" % name
lut = sanitize(lut)
generate_1d_LUT_from_CTL(
os.path.join(lut_directory, lut),
ctls,
lut_resolution_1d,
"float",
input_scale,
1.0,
{"middleGrey": middle_grey, "minExposure": min_exposure, "maxExposure": max_exposure},
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"}
)
cs.from_reference_transforms = []
return cs
示例5: create_dolbypq
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
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):
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.equality_group = name
cs.family = 'Utility'
cs.is_data = False
ctls = [os.path.join(
aces_CTL_directory,
'utilities',
'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name
lut = sanitize(lut)
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'})
cs.from_reference_transforms = []
return cs
示例6: create_ACEScg
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_ACEScg():
"""
Creates the *ACEScg* colorspace.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
Colorspace
*ACEScg* colorspace.
"""
name = 'ACEScg'
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = ['acescg', 'lin_ap1']
cs.equality_group = ''
cs.family = 'ACES'
cs.is_data = False
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
cs.aces_transform_id = 'ACEScsc.ACEScg_to_ACES.a1.0.0'
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 = []
# *AP1* primaries to *AP0* primaries
cs.from_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP0_TO_AP1),
'direction': 'forward'})
return cs
示例7: create_ACEScg
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_ACEScg(aces_ctl_directory, lut_directory, lut_resolution_1d, cleanup, name="ACEScg"):
"""
Creates the *ACEScg* colorspace.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
Colorspace
*ACEScg* colorspace.
"""
cs = ColorSpace(name)
cs.description = "The %s color space" % name
cs.aliases = ["acescg", "lin_ap1"]
cs.equality_group = ""
cs.family = "ACES"
cs.is_data = False
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
cs.aces_transform_id = "ACEScsc.ACEScg_to_ACES.a1.0.0"
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 = []
# *AP1* primaries to *AP0* primaries.
cs.from_reference_transforms.append(
{"type": "matrix", "matrix": mat44_from_mat33(ACES_AP0_TO_AP1), "direction": "forward"}
)
return cs
示例8: create_ACEScg
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_ACEScg(aces_ctl_directory,
lut_directory,
lut_resolution_1d,
cleanup,
name='ACEScg'):
"""
Creates the *ACEScg* colorspace.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
Colorspace
*ACEScg* colorspace.
"""
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = ["lin_ap1"]
cs.equality_group = ''
cs.family = 'ACES'
cs.is_data = False
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
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
示例9: create_v_log
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_v_log(gamut,
transfer_function,
lut_directory,
lut_resolution_1d,
aliases):
"""
Object description.
Panasonic V-Log to ACES.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
type
Return value description.
"""
name = '%s - %s' % (transfer_function, gamut)
if transfer_function == '':
name = 'Linear - %s' % gamut
if gamut == '':
name = 'Curve - %s' % transfer_function
cs = ColorSpace(name)
cs.description = name
cs.aliases = aliases
cs.equality_group = ''
cs.family = 'Input/Panasonic'
cs.is_data = False
# A linear space needs allocation variables
if transfer_function == '':
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
def v_log_to_linear(x):
cut_inv = 0.181
b = 0.00873
c = 0.241514
d = 0.598206
if x <= cut_inv:
return (x - 0.125) / 5.6
else:
return pow(10, (x - d) / c) - b
cs.to_reference_transforms = []
if transfer_function == 'V-Log':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = v_log_to_linear(float(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,
data,
lut_resolution_1d,
1)
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'linear',
'direction': 'forward'})
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],
'direction': 'forward'})
cs.from_reference_transforms = []
return cs
示例10: create_c_log
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_c_log(gamut,
transfer_function,
lut_directory,
lut_resolution_1d,
aliases):
"""
Creates colorspace covering the conversion from CLog to ACES, with various transfer
functions and encoding gamuts covered
Parameters
----------
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
-------
ColorSpace
A ColorSpace container class referencing the LUTs, matrices and identifying
information for the requested colorspace.
"""
name = '%s - %s' % (transfer_function, gamut)
if transfer_function == '':
name = 'Linear - Canon %s' % gamut
if gamut == '':
name = 'Curve - %s' % transfer_function
cs = ColorSpace(name)
cs.description = name
cs.aliases = aliases
cs.equality_group = ''
cs.family = 'Input/Canon'
cs.is_data = False
# A linear space needs allocation variables.
if transfer_function == '':
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
def legal_to_full(code_value):
return (code_value - 64) / (940 - 64)
def c_log_to_linear(code_value):
# log = fullToLegal(c1 * log10(c2*linear + 1) + c3)
# linear = (pow(10, (legalToFul(log) - c3)/c1) - 1)/c2
c1 = 0.529136
c2 = 10.1596
c3 = 0.0730597
linear = (pow(10, (legal_to_full(code_value) - c3) / c1) - 1) / c2
linear *= 0.9
return linear
def c_log2_to_linear(code_value):
# log = fullToLegal(c1 * log10(c2*linear + 1) + c3)
# linear = (pow(10, (legalToFul(log) - c3)/c1) - 1)/c2
c1 = 0.281863093
c2 = 87.09937546
c3 = 0.035388128
linear = (pow(10, (legal_to_full(code_value) - c3) / c1) - 1) / c2
linear *= 0.9
return linear
cs.to_reference_transforms = []
if transfer_function:
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 * c / (lut_resolution_1d - 1))
elif transfer_function == 'Canon-Log2':
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = c_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,
1,
data,
lut_resolution_1d,
1)
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'linear',
'direction': 'forward'})
#.........这里部分代码省略.........
示例11: create_ACES_RRT_plus_ODT
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
#.........这里部分代码省略.........
'direction': 'inverse'}
# Generating the *forward* transform.
cs.from_reference_transforms = []
if 'transformLUT' in odt_values:
transform_lut_file_name = os.path.basename(
odt_values['transformLUT'])
lut = os.path.join(lut_directory, transform_lut_file_name)
shutil.copy(odt_values['transformLUT'], lut)
cs.from_reference_transforms.append(shaper_ocio_transform)
cs.from_reference_transforms.append({
'type': 'lutFile',
'path': transform_lut_file_name,
'interpolation': 'tetrahedral',
'direction': 'forward'})
elif 'transformCTL' in odt_values:
ctls = [
shaper_to_aces_ctl % aces_ctl_directory,
os.path.join(aces_ctl_directory,
'rrt',
'RRT.a1.0.0.ctl'),
os.path.join(aces_ctl_directory,
'odt',
odt_values['transformCTL'])]
lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
lut = sanitize(lut)
generate_3d_LUT_from_CTL(
os.path.join(lut_directory, lut),
ctls,
lut_resolution_3d,
'float',
1 / shaper_input_scale,
1,
shaper_params,
cleanup,
aces_ctl_directory)
cs.from_reference_transforms.append(shaper_ocio_transform)
cs.from_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'tetrahedral',
'direction': 'forward'})
# Generating the *inverse* transform.
cs.to_reference_transforms = []
if 'transformLUTInverse' in odt_values:
transform_lut_inverse_file_name = os.path.basename(
odt_values['transformLUTInverse'])
lut = os.path.join(lut_directory, transform_lut_inverse_file_name)
shutil.copy(odt_values['transformLUTInverse'], lut)
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': transform_lut_inverse_file_name,
'interpolation': 'tetrahedral',
'direction': 'forward'})
shaper_inverse = shaper_ocio_transform.copy()
shaper_inverse['direction'] = 'forward'
cs.to_reference_transforms.append(shaper_inverse)
elif 'transformCTLInverse' in odt_values:
ctls = [os.path.join(aces_ctl_directory,
'odt',
odt_values['transformCTLInverse']),
os.path.join(aces_ctl_directory,
'rrt',
'InvRRT.a1.0.0.ctl'),
shaper_from_aces_ctl % aces_ctl_directory]
lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
lut = sanitize(lut)
generate_3d_LUT_from_CTL(
os.path.join(lut_directory, lut),
ctls,
lut_resolution_3d,
'half',
1,
shaper_input_scale,
shaper_params,
cleanup,
aces_ctl_directory)
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'tetrahedral',
'direction': 'forward'})
shaper_inverse = shaper_ocio_transform.copy()
shaper_inverse['direction'] = 'forward'
cs.to_reference_transforms.append(shaper_inverse)
return cs
示例12: create_ACES_RRT_plus_ODT
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_ACES_RRT_plus_ODT(
odt_name,
odt_values,
shaper_info,
aces_ctl_directory,
lut_directory,
lut_resolution_1d=1024,
lut_resolution_3d=64,
cleanup=True,
aliases=None,
):
"""
Object description.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
type
Return value description.
"""
if aliases is None:
aliases = []
cs = ColorSpace("%s" % odt_name)
cs.description = "%s - %s Output Transform" % (odt_values["transformUserNamePrefix"], odt_name)
cs.aliases = aliases
cs.equality_group = ""
cs.family = "Output"
cs.is_data = False
cs.aces_transform_id = odt_values["transformID"]
pprint.pprint(odt_values)
# Generating the *shaper* transform.
(shaper_name, shaper_to_ACES_CTL, shaper_from_ACES_CTL, shaper_input_scale, shaper_params) = shaper_info
if "legalRange" in odt_values:
shaper_params["legalRange"] = odt_values["legalRange"]
else:
shaper_params["legalRange"] = 0
# Add the shaper transform
shaper_lut = "%s_to_linear.spi1d" % shaper_name
shaper_lut = sanitize(shaper_lut)
shaper_OCIO_transform = {"type": "lutFile", "path": shaper_lut, "interpolation": "linear", "direction": "inverse"}
# Generating the *forward* transform.
cs.from_reference_transforms = []
if "transformLUT" in odt_values:
transform_LUT_file_name = os.path.basename(odt_values["transformLUT"])
lut = os.path.join(lut_directory, transform_LUT_file_name)
shutil.copy(odt_values["transformLUT"], lut)
cs.from_reference_transforms.append(shaper_OCIO_transform)
cs.from_reference_transforms.append(
{"type": "lutFile", "path": transform_LUT_file_name, "interpolation": "tetrahedral", "direction": "forward"}
)
elif "transformCTL" in odt_values:
ctls = [
shaper_to_ACES_CTL % aces_ctl_directory,
os.path.join(aces_ctl_directory, "rrt", "RRT.a1.0.0.ctl"),
os.path.join(aces_ctl_directory, "odt", odt_values["transformCTL"]),
]
lut = "%s.RRT.a1.0.0.%s.spi3d" % (shaper_name, odt_name)
lut = sanitize(lut)
generate_3d_LUT_from_CTL(
os.path.join(lut_directory, lut),
# shaperLUT,
ctls,
lut_resolution_3d,
"float",
1 / shaper_input_scale,
1,
shaper_params,
cleanup,
aces_ctl_directory,
)
cs.from_reference_transforms.append(shaper_OCIO_transform)
cs.from_reference_transforms.append(
{"type": "lutFile", "path": lut, "interpolation": "tetrahedral", "direction": "forward"}
)
# Generating the *inverse* transform.
cs.to_reference_transforms = []
if "transformLUTInverse" in odt_values:
transform_LUT_inverse_file_name = os.path.basename(odt_values["transformLUTInverse"])
lut = os.path.join(lut_directory, transform_LUT_inverse_file_name)
shutil.copy(odt_values["transformLUTInverse"], lut)
#.........这里部分代码省略.........
示例13: create_s_log
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_s_log(gamut,
transfer_function,
lut_directory,
lut_resolution_1d,
aliases):
"""
Creates colorspace covering the conversion from Sony spaces to ACES, with various
transfer functions and encoding gamuts covered
Parameters
----------
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
-------
ColorSpace
A ColorSpace container class referencing the LUTs, matrices and identifying
information for the requested colorspace.
"""
name = '%s - %s' % (transfer_function, gamut)
if transfer_function == '':
name = 'Linear - %s' % gamut
if gamut == '':
name = 'Curve - %s' % transfer_function
cs = ColorSpace(name)
cs.description = name
cs.aliases = aliases
cs.equality_group = ''
cs.family = 'Input/Sony'
cs.is_data = False
if gamut and transfer_function:
cs.aces_transform_id = 'IDT.Sony.%s_%s_10i.a1.v1' % (
transfer_function.replace('-', ''),
gamut.replace('-', '').replace(' ', '_'))
# A linear space needs allocation variables.
if transfer_function == '':
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
def s_log1_to_linear(s_log):
b = 64.
ab = 90.
w = 940.
if s_log >= ab:
linear = ((pow(10.,
(((s_log - b) /
(w - b) - 0.616596 - 0.03) / 0.432699)) -
0.037584) * 0.9)
else:
linear = (((s_log - b) / (
w - b) - 0.030001222851889303) / 5.) * 0.9
return linear
def s_log2_to_linear(s_log):
b = 64.
ab = 90.
w = 940.
if s_log >= ab:
linear = ((219. * (pow(10.,
(((s_log - b) /
(w - b) - 0.616596 - 0.03) / 0.432699)) -
0.037584) / 155.) * 0.9)
else:
linear = (((s_log - b) / (
w - b) - 0.030001222851889303) / 3.53881278538813) * 0.9
return linear
def s_log3_to_linear(code_value):
if code_value >= 171.2102946929:
linear = (pow(10, ((code_value - 420) / 261.5)) *
(0.18 + 0.01) - 0.01)
else:
linear = (code_value - 95) * 0.01125000 / (171.2102946929 - 95)
return linear
cs.to_reference_transforms = []
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 * c / (lut_resolution_1d - 1))
lut = '%s_to_linear.spi1d' % transfer_function
genlut.write_SPI_1d(
#.........这里部分代码省略.........
示例14: create_matrix_plus_transfer_colorspace
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_matrix_plus_transfer_colorspace(
name='matrix_plus_transfer',
transfer_function_name='transfer_function',
transfer_function=lambda x: x,
lut_directory='/tmp',
lut_resolution_1d=1024,
from_reference_values=None,
to_reference_values=None,
aliases=None):
"""
Creates a ColorSpace that uses transfer functions encoded as 1D LUTs and
matrice
Parameters
----------
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
-------
ColorSpace
A *Matrx and LUT1D Transform*-based ColorSpace representing a transfer
function and matrix
"""
if from_reference_values is None:
from_reference_values = []
if to_reference_values is None:
to_reference_values = []
if aliases is None:
aliases = []
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
cs.equality_group = name
cs.family = 'Utility'
cs.is_data = False
# A linear space needs allocation variables.
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
# Sampling the transfer function.
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = transfer_function(c / (lut_resolution_1d - 1))
# Writing the sampled data to a *LUT*.
lut = '%s_to_linear.spi1d' % transfer_function_name
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
0,
1,
data,
lut_resolution_1d,
1)
# Creating the *to_reference* transforms.
cs.to_reference_transforms = []
if to_reference_values:
cs.to_reference_transforms.append({
'type': 'lutFile',
'path': lut,
'interpolation': 'linear',
'direction': 'forward'})
for matrix in to_reference_values:
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(matrix),
'direction': 'forward'})
# Creating the *from_reference* transforms.
cs.from_reference_transforms = []
if from_reference_values:
for matrix in from_reference_values:
cs.from_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(matrix),
'direction': 'forward'})
cs.from_reference_transforms.append({
'type': 'lutFile',
#.........这里部分代码省略.........
示例15: create_log_c
# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import to_reference_transforms [as 别名]
def create_log_c(gamut,
transfer_function,
exposure_index,
name,
lut_directory,
lut_resolution_1d,
aliases):
"""
Object description.
LogC to ACES.
Parameters
----------
parameter : type
Parameter description.
Returns
-------
type
Return value description.
"""
name = '%s (EI%s) - %s' % (transfer_function, exposure_index, gamut)
if transfer_function == '':
name = 'Linear - ARRI %s' % gamut
if gamut == '':
name = '%s (EI%s)' % (transfer_function, exposure_index)
cs = ColorSpace(name)
cs.description = name
cs.aliases = aliases
cs.equality_group = ''
cs.family = 'Input/ARRI'
cs.is_data = False
# A linear space needs allocation variables
if transfer_function == '':
cs.allocation_type = ocio.Constants.ALLOCATION_LG2
cs.allocation_vars = [-8, 5, 0.00390625]
# Globals.
IDT_maker_version = '0.08'
nominal_EI = 400
black_signal = 0.003907
mid_gray_signal = 0.01
encoding_gain = 0.256598
encoding_offset = 0.391007
def gain_for_EI(EI):
return (math.log(EI / nominal_EI) / math.log(2) * (
0.89 - 1) / 3 + 1) * encoding_gain
def log_c_inverse_parameters_for_EI(EI):
cut = 1 / 9
slope = 1 / (cut * math.log(10))
offset = math.log10(cut) - slope * cut
gain = EI / nominal_EI
gray = mid_gray_signal / gain
# The higher the EI, the lower the gamma.
enc_gain = gain_for_EI(EI)
enc_offset = encoding_offset
for i in range(0, 3):
nz = ((95 / 1023 - enc_offset) / enc_gain - offset) / slope
enc_offset = encoding_offset - math.log10(1 + nz) * enc_gain
a = 1 / gray
b = nz - black_signal / gray
e = slope * a * enc_gain
f = enc_gain * (slope * b + offset) + enc_offset
# Ensuring we can return relative exposure.
s = 4 / (0.18 * EI)
t = black_signal
b += a * t
a *= s
f += e * t
e *= s
return {'a': a,
'b': b,
'cut': (cut - b) / a,
'c': enc_gain,
'd': enc_offset,
'e': e,
'f': f}
def log_c_to_linear(code_value, exposure_index):
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 - p['d']) / p['c']) -
p['b']) / p['a'])
else:
linear = (code_value / 1023 - p['f']) / p['e']
return linear
cs.to_reference_transforms = []
#.........这里部分代码省略.........