当前位置: 首页>>代码示例>>Python>>正文


Python ColorSpace.from_reference_transforms方法代码示例

本文整理汇总了Python中aces_ocio.utilities.ColorSpace.from_reference_transforms方法的典型用法代码示例。如果您正苦于以下问题:Python ColorSpace.from_reference_transforms方法的具体用法?Python ColorSpace.from_reference_transforms怎么用?Python ColorSpace.from_reference_transforms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aces_ocio.utilities.ColorSpace的用法示例。


在下文中一共展示了ColorSpace.from_reference_transforms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_transfer_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:cynlangley,项目名称:OpenColorIO-Configs,代码行数:60,代码来源:general.py

示例2: create_matrix_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:57,代码来源:general.py

示例3: create_Dolby_PQ_scaled

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:56,代码来源:aces.py

示例4: create_dolbypq_scaled

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:cynlangley,项目名称:OpenColorIO-Configs,代码行数:49,代码来源:aces.py

示例5: create_dolbypq

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:taka25,项目名称:OpenColorIO-Configs,代码行数:48,代码来源:create_aces_colorspaces.py

示例6: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:47,代码来源:aces.py

示例7: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:cynlangley,项目名称:OpenColorIO-Configs,代码行数:43,代码来源:aces.py

示例8: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:taka25,项目名称:OpenColorIO-Configs,代码行数:40,代码来源:create_aces_colorspaces.py

示例9: create_v_log

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:85,代码来源:panasonic.py

示例10: create_c_log

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_reference_transforms [as 别名]

#.........这里部分代码省略.........

        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'})

    if gamut == 'Rec. 709 Daylight':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            '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.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.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.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.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.035361374, 1.065690585, -0.030329211, 0,
                       0.010390366, -0.299271107, 1.288880741, 0,
                       0, 0, 0, 1],
            'direction': 'forward'})
    elif gamut == 'Rec. 2020 Daylight':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': [0.678891151, 0.158868422, 0.162240427, 0,
                       0.045570831, 0.860712772, 0.093716397, 0,
                       -0.000485710, 0.025060196, 0.975425515, 0,
                       0, 0, 0, 1],
            'direction': 'forward'})
    elif gamut == 'Rec. 2020 Tungsten':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': [0.724488568, 0.115140904, 0.160370529, 0,
                       0.010659276, 0.839605344, 0.149735380, 0,
                       0.014560161, 0.028562057, 1.014001897, 0,
                       0, 0, 0, 1],
            'direction': 'forward'})

    cs.from_reference_transforms = []
    return cs
开发者ID:colour-science,项目名称:OpenColorIO-Configs,代码行数:104,代码来源:canon.py

示例11: create_ACES_RRT_plus_ODT

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_reference_transforms [as 别名]
def create_ACES_RRT_plus_ODT(odt_name,
                             odt_values,
                             shaper_info,
                             aces_ctl_directory,
                             lut_directory,
                             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

    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),
            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',
#.........这里部分代码省略.........
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:aces.py

示例12: create_ACES_RRT_plus_ODT

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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)
#.........这里部分代码省略.........
开发者ID:cynlangley,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:aces.py

示例13: create_s_log

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_reference_transforms [as 别名]

#.........这里部分代码省略.........
        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(
            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'})
    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 * 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'})
    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 * 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'})

    if gamut == 'S-Gamut':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33(
                [0.754338638, 0.133697046, 0.111968437,
                 0.021198141, 1.005410934, -0.026610548,
                 -0.009756991, 0.004508563, 1.005253201]),
            'direction': 'forward'})
    elif gamut == 'S-Gamut Daylight':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33(
                [0.8764457030, 0.0145411681, 0.1090131290,
                 0.0774075345, 0.9529571767, -0.0303647111,
                 0.0573564351, -0.1151066335, 1.0577501984]),
            'direction': 'forward'})
    elif gamut == 'S-Gamut Tungsten':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33(
                [1.0110238740, -0.1362526051, 0.1252287310,
                 0.1011994504, 0.9562196265, -0.0574190769,
                 0.0600766530, -0.1010185315, 1.0409418785]),
            'direction': 'forward'})
    elif gamut == 'S-Gamut3.Cine':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33(
                [0.6387886672, 0.2723514337, 0.0888598992,
                 -0.0039159061, 1.0880732308, -0.0841573249,
                 -0.0299072021, -0.0264325799, 1.0563397820]),
            'direction': 'forward'})
    elif gamut == 'S-Gamut3':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33(
                [0.7529825954, 0.1433702162, 0.1036471884,
                 0.0217076974, 1.0153188355, -0.0370265329,
                 -0.0094160528, 0.0033704179, 1.0060456349]),
            'direction': 'forward'})

    cs.from_reference_transforms = []
    return cs
开发者ID:MrKepzie,项目名称:OpenColorIO-Configs,代码行数:104,代码来源:sony.py

示例14: create_matrix_plus_transfer_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_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',
#.........这里部分代码省略.........
开发者ID:lucienfostier,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:general.py

示例15: create_log_c

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import from_reference_transforms [as 别名]

#.........这里部分代码省略.........
    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 = []

    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 * c / (lut_resolution_1d - 1),
                                      int(exposure_index))

        lut = '%s_to_linear.spi1d' % (
            '%s_%s' % (transfer_function, exposure_index))

        lut = sanitize(lut)

        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'
        })

    if gamut == 'Wide Gamut':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33([0.680206, 0.236137, 0.083658,
                                        0.085415, 1.017471, -0.102886,
                                        0.002057, -0.062563, 1.060506]),
            'direction': 'forward'
        })

    cs.from_reference_transforms = []
    return cs
开发者ID:taka25,项目名称:OpenColorIO-Configs,代码行数:104,代码来源:create_arri_colorspaces.py


注:本文中的aces_ocio.utilities.ColorSpace.from_reference_transforms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。