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


Python ColorSpace.allocation_vars方法代码示例

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


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

示例1: create_ACES

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_ACES():
    """
    Object description.

    Parameters
    ----------
    parameter : type
        Parameter description.

    Returns
    -------
    type
         Return value description.
    """

    # Defining the reference colorspace.
    aces2065_1 = ColorSpace('ACES2065-1')
    aces2065_1.description = (
        'The Academy Color Encoding System reference color space')
    aces2065_1.equality_group = ''
    aces2065_1.aliases = ['lin_ap0', 'aces']
    aces2065_1.family = 'ACES'
    aces2065_1.is_data = False
    aces2065_1.allocation_type = ocio.Constants.ALLOCATION_LG2
    aces2065_1.allocation_vars = [-8, 5, 0.00390625]

    return aces2065_1
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:29,代码来源:aces.py

示例2: create_transfer_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例3: create_matrix_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例4: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例5: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例6: create_ACEScg

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例7: create_protune

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_protune(gamut,
                   transfer_function,
                   lut_directory,
                   lut_resolution_1d,
                   aliases):
    """
    Creates colorspace covering the conversion from ProTune 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.
    """

    # The gamut should be marked as experimental until  matrices are fully
    # verified.
    name = '%s - %s - Experimental' % (transfer_function, gamut)
    if transfer_function == '':
        name = 'Linear - %s - Experimental' % gamut
    if gamut == '':
        name = 'Curve - %s' % transfer_function

    cs = ColorSpace(name)
    cs.description = name
    cs.aliases = aliases
    cs.equality_group = ''
    cs.family = 'Input/GoPro'
    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 protune_to_linear(normalized_code_value):
        c1 = 113.0
        c2 = 1.0
        c3 = 112.0
        linear = ((pow(c1, normalized_code_value) - c2) / c3)

        return linear

    cs.to_reference_transforms = []

    if transfer_function == 'Protune Flat':
        data = array.array('f', '\0' * lut_resolution_1d * 4)
        for c in range(lut_resolution_1d):
            data[c] = protune_to_linear(float(c) / (lut_resolution_1d - 1))

        lut = '%s_to_linear.spi1d' % transfer_function
        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 == 'Protune Native':
        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,
                       0, 0, 0, 1],
            'direction': 'forward'})

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

示例8: create_red_log_film

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_red_log_film(gamut,
                        transfer_function,
                        lut_directory,
                        lut_resolution_1d,
                        aliases=None):
    """
    Creates colorspace covering the conversion from RED 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.
    """

    if aliases is None:
        aliases = []

    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/RED'
    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 cineon_to_linear(code_value):
        n_gamma = 0.6
        black_point = 95
        white_point = 685
        code_value_to_density = 0.002

        black_linear = pow(10, (black_point - white_point) * (
            code_value_to_density / n_gamma))
        code_linear = pow(10, (code_value - white_point) * (
            code_value_to_density / n_gamma))

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

        lut = 'CineonLog_to_linear.spi1d'
        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 == 'DRAGONcolor':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33([0.532279, 0.376648, 0.091073,
                                        0.046344, 0.974513, -0.020860,
                                        -0.053976, -0.000320, 1.054267]),
            'direction': 'forward'})
    elif gamut == 'DRAGONcolor2':
        cs.to_reference_transforms.append({
            'type': 'matrix',
            'matrix': mat44_from_mat33([0.468452, 0.331484, 0.200064,
                                        0.040787, 0.857658, 0.101553,
                                        -0.047504, -0.000282, 1.047756]),
            'direction': 'forward'})
    elif gamut == 'REDcolor':
#.........这里部分代码省略.........
开发者ID:MrKepzie,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:red.py

示例9: create_c_log

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

示例10: create_v_log

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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

示例11: create_ACES_LMT

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_ACES_LMT(lmt_name,
                    lmt_values,
                    shaper_info,
                    aces_ctl_directory,
                    lut_directory,
                    lut_resolution_3d=64,
                    cleanup=True,
                    aliases=None):
    """
    Creates the *ACES LMT* colorspace.

    Parameters
    ----------
    parameter : type
        Parameter description.

    Returns
    -------
    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
    cs.equality_group = ''
    cs.family = 'Look'
    cs.is_data = False
    cs.allocation_type = ocio.Constants.ALLOCATION_LG2
    cs.allocation_vars = [-8, 5, 0.00390625]
    cs.aces_transform_id = lmt_values['transformID']

    pprint.pprint(lmt_values)

    # Generating the *shaper* transform.
    (shaper_name,
     shaper_to_aces_ctl,
     shaper_from_aces_ctl,
     shaper_input_scale,
     shaper_params) = shaper_info

    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 'transformCTL' in lmt_values:
        ctls = [shaper_to_aces_ctl % aces_ctl_directory,
                os.path.join(aces_ctl_directory,
                             lmt_values['transformCTL'])]
        lut = '%s.%s.spi3d' % (shaper_name, lmt_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 'transformCTLInverse' in lmt_values:
        ctls = [os.path.join(aces_ctl_directory,
                             lmt_values['transformCTLInverse']),
                shaper_from_aces_ctl % aces_ctl_directory]
        lut = 'Inverse.%s.%s.spi3d' % (lmt_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,
#.........这里部分代码省略.........
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:aces.py

示例12: create_s_log

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_s_log(gamut,
                 transfer_function,
                 name,
                 lut_directory,
                 lut_resolution_1d,
                 aliases):
    """
    Object description.

    SLog 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 = '%s' % transfer_function

    cs = ColorSpace(name)
    cs.description = name
    cs.aliases = aliases
    cs.equality_group = ''
    cs.family = 'Input/Sony'
    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 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(
            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'})
#.........这里部分代码省略.........
开发者ID:taka25,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:create_sony_colorspaces.py

示例13: create_log_c

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_log_c(gamut, transfer_function, exposure_index, 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 = "Curve - %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

    if gamut and transfer_function:
        cs.aces_transform_id = "IDT.ARRI.Alexa-v3-logC-EI%s.a1.v1" % exposure_index

    # A linear space needs allocation variables.
    if transfer_function == "":
        cs.allocation_type = ocio.Constants.ALLOCATION_LG2
        cs.allocation_vars = [-8, 5, 0.00390625]

    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 normalized_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 - p["d"]) / p["c"]) - p["b"]) / p["a"]
        else:
            linear = (code_value - 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] = normalized_log_c_to_linear(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(
#.........这里部分代码省略.........
开发者ID:Dithermaster,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:arri.py

示例14: create_log_c

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [as 别名]
def create_log_c(gamut,
                 transfer_function,
                 exposure_index,
                 lut_directory,
                 lut_resolution_1d,
                 aliases):
    """
    Creates colorspace covering the conversion from LogC 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
    exposure_index : str
        The exposure index 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 (EI%s) - %s' % (transfer_function, exposure_index, gamut)
    if transfer_function == '':
        name = 'Linear - ARRI %s' % gamut
    if gamut == '':
        name = 'Curve - %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

    if gamut and transfer_function:
        cs.aces_transform_id = (
            'IDT.ARRI.Alexa-v3-logC-EI%s.a1.v1' % exposure_index)

    # A linear space needs allocation variables.
    if transfer_function == '':
        cs.allocation_type = ocio.Constants.ALLOCATION_LG2
        cs.allocation_vars = [-8, 5, 0.00390625]

    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}

#.........这里部分代码省略.........
开发者ID:MrKepzie,项目名称:OpenColorIO-Configs,代码行数:103,代码来源:arri.py

示例15: create_matrix_plus_transfer_colorspace

# 需要导入模块: from aces_ocio.utilities import ColorSpace [as 别名]
# 或者: from aces_ocio.utilities.ColorSpace import allocation_vars [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


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