Esempio n. 1
0
def create_builtin_transform(style):
    """
    Creates an *OpenColorIO* builtin transform for given style.

    If the style does not exist, a placeholder transform is used in place
    of the builtin transform.

    Parameters
    ----------
    style : unicode
        *OpenColorIO* builtin transform style

    Returns
    -------
    BuiltinTransform
        *OpenColorIO* builtin transform for given style.
    """

    import PyOpenColorIO as ocio

    builtin_transform = ocio.BuiltinTransform()

    try:
        builtin_transform.setStyle(style)
    except ocio.Exception:
        logging.warning(f'{style} style is not defined, '
                        f'using a placeholder "FileTransform" instead!')
        builtin_transform = ocio.FileTransform()
        builtin_transform.setSrc(style)

    return builtin_transform
Esempio n. 2
0
    def test_constructor_positional(self):
        # Positional args
        builtin_tr = OCIO.BuiltinTransform(self.EXAMPLE_STYLE,
                                           OCIO.TRANSFORM_DIR_FORWARD)

        self.assertEqual(builtin_tr.getStyle(), self.EXAMPLE_STYLE)
        self.assertEqual(builtin_tr.getDescription(), self.EXAMPLE_DESC)
        self.assertEqual(builtin_tr.getDirection(), OCIO.TRANSFORM_DIR_FORWARD)
Esempio n. 3
0
    def test_constructor_keyword(self):
        # Keyword args in order
        builtin_tr1 = OCIO.BuiltinTransform(
            style=self.EXAMPLE_STYLE, direction=OCIO.TRANSFORM_DIR_FORWARD)

        self.assertEqual(builtin_tr1.getStyle(), self.EXAMPLE_STYLE)
        self.assertEqual(builtin_tr1.getDescription(), self.EXAMPLE_DESC)
        self.assertEqual(builtin_tr1.getDirection(),
                         OCIO.TRANSFORM_DIR_FORWARD)

        # Keyword args out of order
        builtin_tr2 = OCIO.BuiltinTransform(
            direction=OCIO.TRANSFORM_DIR_FORWARD, style=self.EXAMPLE_STYLE)

        self.assertEqual(builtin_tr2.getStyle(), self.EXAMPLE_STYLE)
        self.assertEqual(builtin_tr2.getDescription(), self.EXAMPLE_DESC)
        self.assertEqual(builtin_tr2.getDirection(),
                         OCIO.TRANSFORM_DIR_FORWARD)
Esempio n. 4
0
def style_to_display_colorspace(style,
                                describe=ColorspaceDescriptionStyle.
                                OPENCOLORIO,
                                **kwargs):
    """
    Creates an *OpenColorIO* display colorspace for given style.

    Parameters
    ----------
    style : unicode
        *OpenColorIO* builtin transform style
    describe : int, optional
        Any value from the
        :class:`opencolorio_config_aces.ColorspaceDescriptionStyle` enum.
    Other Parameters
    ----------------
    \\**kwargs : dict, optional
        Keywords arguments for the
        :func:`opencolorio_config_aces.colorspace_factory` definition.

    Returns
    -------
    ColorSpace
        *OpenColorIO* display colorspace for given style.
    """

    import PyOpenColorIO as ocio

    kwargs.setdefault('family', ACES_CONFIG_DISPLAY_FAMILY)

    name = beautify_display_name(style)
    builtin_transform = ocio.BuiltinTransform(style)

    description = None
    if describe != ColorspaceDescriptionStyle.NONE:
        description = []

        if describe in (ColorspaceDescriptionStyle.OPENCOLORIO,
                        ColorspaceDescriptionStyle.SHORT_UNION,
                        ColorspaceDescriptionStyle.LONG_UNION):
            description.append(builtin_transform.getDescription())

        description = '\n'.join(description)

    settings = {
        'name': name,
        'family': ACES_CONFIG_DISPLAY_FAMILY,
        'description': description,
        'from_reference': builtin_transform,
        'reference_space': ocio.REFERENCE_SPACE_DISPLAY,
    }
    settings.update(kwargs)

    colorspace = colorspace_factory(**settings)

    return colorspace
Esempio n. 5
0
def get_camera_colorspaces(family=""):
    colorspaces = []
    # get Camera Log colorspaces from Builtins
    for name, description in ocio.BuiltinTransformRegistry().getBuiltins():
        if name.endswith("to_ACES2065-1"):
            colorspaces.append(
                ocio.ColorSpace(
                    name=description.split("Convert ")[-1].split(" to ")[0],
                    family=family,
                    encoding="log",
                    toReference=ocio.BuiltinTransform(name),
                ))
    return colorspaces
    def test_color_timing_cc(self):
        """
        Test the get/setColorTimingCC functions.
        """
        pipeline = OCIO.LegacyViewingPipeline()
        self.assertEqual(pipeline.getColorTimingCC(), None)
        bi = OCIO.BuiltinTransform()
        bi.setStyle('IDENTITY')
        pipeline.setColorTimingCC(bi)
        t = pipeline.getColorTimingCC()
        self.assertEqual(t.getTransformType(), OCIO.TRANSFORM_TYPE_BUILTIN)
        t.__class__ = OCIO.BuiltinTransform
        self.assertEqual(t.getStyle(), 'IDENTITY')
        pipeline.setColorTimingCC(None)
        self.assertEqual(pipeline.getColorTimingCC(), None)

        with self.assertRaises(TypeError):
            pipeline.setColorTimingCC()
        with self.assertRaises(TypeError):
            pipeline.setColorTimingCC(OCIO.TRANSFORM_DIR_FORWARD)
        with self.assertRaises(TypeError):
            pipeline.setColorTimingCC(False)
Esempio n. 7
0
def generate_config_aces(
        config_name=None,
        validate=True,
        describe=ColorspaceDescriptionStyle.SHORT_UNION,
        config_mapping_file_path=ACES_CONFIG_REFERENCE_MAPPING_FILE_PATH,
        analytical=True,
        additional_data=False):
    """
    Generates the *aces-dev* reference implementation *OpenColorIO* Config
    using the *Mapping* method.

    The Config generation is constrained by a *CSV* file exported from the
    *Reference Config - Mapping* sheet from a
    `Google Sheets file <https://docs.google.com/spreadsheets/d/\
    1SXPt-USy3HlV2G2qAvh9zit6ZCINDOlfKT07yXJdWLg>`__. The *Google Sheets* file
    was originally authored using the output of the *aces-dev* conversion graph
    to support the discussions of the *OpenColorIO* *Working Group* on the
    design of the  *aces-dev* reference implementation *OpenColorIO* Config.
    The resulting mapping is the outcome of those discussions and leverages the
    new *OpenColorIO 2* display architecture while factoring many transforms.

    Parameters
    ----------
    config_name : unicode, optional
        *OpenColorIO* config file name, if given the config will be written to
        disk.
    validate : bool, optional
        Whether to validate the config.
    describe : int, optional
        Any value from the
        :class:`opencolorio_config_aces.ColorspaceDescriptionStyle` enum.
    config_mapping_file_path : unicode, optional
        Path to the *CSV* mapping file used by the *Mapping* method.
    analytical : bool, optional
        Whether to generate *OpenColorIO* transform families that analytically
        match the given *ACES* *CTL* transform, i.e. true to the *aces-dev*
        reference but not necessarily user friendly.
    additional_data : bool, optional
        Whether to return additional data.

    Returns
    -------
    Config or tuple
        *OpenColorIO* config or tuple of *OpenColorIO* config,
        :class:`opencolorio_config_aces.ConfigData` class instance and dict of
        *OpenColorIO* colorspaces and
        :class:`opencolorio_config_aces.config.reference.CTLTransform` class
        instances.
    """

    import PyOpenColorIO as ocio

    ctl_transforms = unclassify_ctl_transforms(
        classify_aces_ctl_transforms(discover_aces_ctl_transforms()))

    builtin_transforms = [
        builtin for builtin in ocio.BuiltinTransformRegistry()
    ]

    config_mapping = defaultdict(list)
    with open(config_mapping_file_path) as csv_file:
        dict_reader = csv.DictReader(csv_file,
                                     delimiter=',',
                                     fieldnames=[
                                         'ordering',
                                         'aces_transform_id',
                                         'builtin_transform_style',
                                         'linked_display_colorspace_style',
                                         'interface',
                                         'encoding',
                                         'categories',
                                     ])

        # Skipping the first header line.
        next(dict_reader)

        for transform_data in dict_reader:
            # Checking whether the "BuiltinTransform" style exists.
            style = transform_data['builtin_transform_style']
            if style:
                assert (style in builtin_transforms), (
                    f'"{style}" "BuiltinTransform" style does not '
                    f'exist!')

            # Checking whether the linked "DisplayColorspace"
            # "BuiltinTransform" style exists.
            style = transform_data['linked_display_colorspace_style']
            if style:
                assert (style in builtin_transforms), (
                    f'"{style}" "BuiltinTransform" style does not '
                    f'exist!')

            # Finding the "CTLTransform" class instance that matches given
            # "ACEStransformID", if it does not exist, there is a critical
            # mismatch in the mapping with *aces-dev*.
            aces_transform_id = transform_data['aces_transform_id']
            filtered_ctl_transforms = [
                ctl_transform for ctl_transform in ctl_transforms
                if ctl_transform.aces_transform_id.aces_transform_id ==
                aces_transform_id
            ]

            ctl_transform = next(iter(filtered_ctl_transforms), None)

            assert ctl_transform is not None, (
                f'"aces-dev" has no transform with "{aces_transform_id}" '
                f'ACEStransformID, please cross-check the '
                f'"{config_mapping_file_path}" config mapping file and '
                f'the "aces-dev" "CTL" transforms!')

            transform_data['ctl_transform'] = ctl_transform

            config_mapping[transform_data['builtin_transform_style']].append(
                transform_data)

    colorspaces = []
    looks = []
    displays, display_names = [], []
    view_transforms, view_transform_names = [], []
    shared_views = []

    aces_family_prefix = 'CSC' if analytical else 'ACES'

    scene_reference_colorspace = colorspace_factory(
        f'{aces_family_prefix} - {ACES_CONFIG_REFERENCE_COLORSPACE}',
        'ACES',
        description=(
            'The "Academy Color Encoding System" reference colorspace.'),
        encoding='scene-linear')

    display_reference_colorspace = colorspace_factory(
        'CIE-XYZ-D65',
        description='The "CIE XYZ (D65)" display connection colorspace.',
        reference_space=ocio.REFERENCE_SPACE_DISPLAY)

    raw_colorspace = colorspace_factory(
        'Utility - Raw',
        'Utility',
        description='The utility "Raw" colorspace.',
        is_data=True)

    colorspaces += [
        scene_reference_colorspace,
        display_reference_colorspace,
        raw_colorspace,
    ]

    for style, transforms_data in config_mapping.items():
        if transforms_data[0]['interface'] == 'ViewTransform':
            view_transform = style_to_view_transform(style, [
                transform_data['ctl_transform']
                for transform_data in transforms_data
            ], describe)
            view_transforms.append(view_transform)
            view_transform_name = view_transform.getName()
            view_transform_names.append(view_transform_name)

            for transform_data in transforms_data:
                display_style = transform_data[
                    'linked_display_colorspace_style']

                display = style_to_display_colorspace(
                    display_style,
                    encoding=transform_data.get('encoding'),
                    categories=transform_data.get('categories'))
                display_name = display.getName()

                if display_name not in display_names:
                    displays.append(display)
                    display_names.append(display_name)

                shared_views.append({
                    'display': display_name,
                    'view': view_transform_name,
                    'view_transform': view_transform_name,
                })
        else:
            for transform_data in transforms_data:
                ctl_transform = transform_data['ctl_transform']

                if transform_data['interface'] == 'Look':
                    look = ctl_transform_to_look(
                        ctl_transform,
                        describe,
                        analytical=analytical,
                        forward_transform=create_builtin_transform(style),
                        process_space=scene_reference_colorspace.getName(),
                    )

                    looks.append(look)
                else:
                    colorspace = ctl_transform_to_colorspace(
                        ctl_transform,
                        describe,
                        analytical=analytical,
                        to_reference=create_builtin_transform(style),
                        encoding=transform_data.get('encoding'),
                        categories=transform_data.get('categories'))

                    colorspaces.append(colorspace)

    untonemapped_view_transform = view_transform_factory(
        'Un-tone-mapped',
        from_reference=ocio.BuiltinTransform(
            'UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD'),
    )
    untonemapped_view_transform_name = untonemapped_view_transform.getName()
    for display in display_names:
        shared_views.append({
            'display': display,
            'view': untonemapped_view_transform_name,
            'view_transform': untonemapped_view_transform_name,
        })

    data = ConfigData(
        description=(
            f'The "Academy Color Encoding System" (ACES) "Reference Config".'
            f'\n\n'
            f'This "OpenColorIO" config is a strict and quasi-analytical '
            f'implementation of "aces-dev" and is designed as a reference for '
            f'software developers. It is not a replacement for the previous '
            f'"ACES" configs nor the "ACES Studio Config".'
            f'\n\n'
            f'Generated with "OpenColorIO-Config-ACES" {git_describe()} '
            f'on the {datetime.now().strftime("%Y/%m/%d at %H:%M")}.'),
        roles={
            ocio.ROLE_COLOR_TIMING: f'{aces_family_prefix} - ACEScct',
            ocio.ROLE_COMPOSITING_LOG: f'{aces_family_prefix} - ACEScct',
            ocio.ROLE_DATA: 'Utility - Raw',
            ocio.ROLE_DEFAULT: scene_reference_colorspace.getName(),
            ocio.ROLE_INTERCHANGE_DISPLAY:
            display_reference_colorspace.getName(),
            ocio.ROLE_INTERCHANGE_SCENE: scene_reference_colorspace.getName(),
            ocio.ROLE_REFERENCE: scene_reference_colorspace.getName(),
            ocio.ROLE_RENDERING: f'{aces_family_prefix} - ACEScg',
            ocio.ROLE_SCENE_LINEAR: f'{aces_family_prefix} - ACEScg',
        },
        colorspaces=colorspaces + displays,
        looks=looks,
        view_transforms=view_transforms + [untonemapped_view_transform],
        shared_views=shared_views,
        views=shared_views + [{
            'display': display,
            'view': 'Raw',
            'colorspace': 'Utility - Raw'
        } for display in display_names],
        active_displays=display_names,
        active_views=view_transform_names + ['Raw'],
        file_rules=[{
            'name': 'Default',
            'colorspace': scene_reference_colorspace.getName()
        }],
        inactive_colorspaces=['CIE-XYZ-D65'],
        default_view_transform=untonemapped_view_transform.getName(),
        profile_version=2)

    config = generate_config(data, config_name, validate)

    if additional_data:
        return config, data
    else:
        return config
Esempio n. 8
0
def style_to_view_transform(style,
                            ctl_transforms,
                            describe=ColorspaceDescriptionStyle.LONG_UNION):
    """
    Creates an *OpenColorIO* view transform for given style.

    Parameters
    ----------
    style : unicode
        *OpenColorIO* builtin transform style
    ctl_transforms : array_like
        Array of :class:`opencolorio_config_aces.config.reference.CTLTransform`
        class instances corresponding to the given style.
    describe : int, optional
        Any value from the
        :class:`opencolorio_config_aces.ColorspaceDescriptionStyle` enum.

    Returns
    -------
    ViewTransform
        *OpenColorIO* view transform for given style.
    """

    import PyOpenColorIO as ocio

    name = beautify_view_transform_name(style)
    builtin_transform = ocio.BuiltinTransform(style)

    description = None
    if describe != ColorspaceDescriptionStyle.NONE:
        description = []

        if describe in (ColorspaceDescriptionStyle.OPENCOLORIO,
                        ColorspaceDescriptionStyle.SHORT_UNION,
                        ColorspaceDescriptionStyle.LONG_UNION):
            description.append(builtin_transform.getDescription())

        if describe in (ColorspaceDescriptionStyle.ACES,
                        ColorspaceDescriptionStyle.ACES
                        | ColorspaceDescriptionStyle.SHORT,
                        ColorspaceDescriptionStyle.SHORT_UNION,
                        ColorspaceDescriptionStyle.LONG_UNION):
            aces_transform_ids, aces_descriptions = zip(
                *[(ctl_transform.aces_transform_id.aces_transform_id,
                   ctl_transform.description)
                  for ctl_transform in ctl_transforms])

            if len(description) > 0:
                description.append('')

            if describe in (ColorspaceDescriptionStyle.ACES
                            | ColorspaceDescriptionStyle.SHORT,
                            ColorspaceDescriptionStyle.SHORT_UNION):
                description.extend([
                    f'ACEStransformID: {aces_transform_id}'
                    for aces_transform_id in aces_transform_ids
                ])
            else:
                description.append(
                    f'CTL Transform'
                    f'{"s" if len(aces_transform_ids) >= 2 else ""}')
                description.append(f'{"=" * len(description[-1])}\n')

                description.append(f'\n{"-" * 80}\n\n'.join([
                    (f'{aces_descriptions[i]}\n\n'
                     f'ACEStransformID: {aces_transform_id}\n')
                    for i, aces_transform_id in enumerate(aces_transform_ids)
                ]))

        description = '\n'.join(description)

    return view_transform_factory(name,
                                  from_reference=builtin_transform,
                                  description=description)
Esempio n. 9
0
 def setUp(self):
     self.builtin_tr = OCIO.BuiltinTransform()
def _add_default_colorspaces_and_roles(config=None, scene_linear="ACEScg"):
    # create default colorspaces

    linear_allocation_vars = [-8, 5, 0.00390625]
    # data / no-color
    raw = ocio.ColorSpace(name="raw", isData=True, equalityGroup="nc", encoding="data")

    # Scene and display reference
    aces = ocio.ColorSpace(
        name="ACES2065-1",
        equalityGroup="ap0",
        encoding="scene-linear",
        allocation=ocio.ALLOCATION_LG2,
        allocationVars=linear_allocation_vars,
    )

    xyzd65 = ocio.ColorSpace(
        name="CIE-XYZ (D65)",
        equalityGroup="xyz",
        encoding="display-linear",
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        allocation=ocio.ALLOCATION_LG2,
        allocationVars=linear_allocation_vars,
    )

    # Other linear reference spaces
    acescg = ocio.ColorSpace(
        name="ACEScg",
        equalityGroup="ap1",
        toReference=ocio.BuiltinTransform("ACEScg_to_ACES2065-1"),
        encoding="scene-linear",
        allocation=ocio.ALLOCATION_LG2,
        allocationVars=linear_allocation_vars,
    )

    lin709 = ocio.ColorSpace(
        name="Linear-Rec709",
        encoding="scene-linear",
        toReference=ocio.GroupTransform(
            [
                ocio.BuiltinTransform(
                    "ACES-AP1_to_LINEAR-REC709_BFD",
                    direction=ocio.TRANSFORM_DIR_INVERSE,
                ),
                ocio.BuiltinTransform("ACEScg_to_ACES2065-1"),
            ]
        ),
        allocation=ocio.ALLOCATION_LG2,
        allocationVars=linear_allocation_vars,
    )

    cfg = config or ocio.GetCurrentConfig()

    # add default colorspaces to config and update roles
    _ = [cfg.addColorSpace(cs) for cs in [raw, aces, xyzd65, acescg, lin709]]

    scene_linear = {acescg.getName(): acescg, lin709.getName(): lin709}[scene_linear]

    cfg.setRole("aces_interchange", aces.getName())
    cfg.setRole("cie_xyz_d65_interchange", xyzd65.getName())
    cfg.setRole(ocio.ROLE_DATA, raw.getName())
    cfg.setRole(ocio.ROLE_DEFAULT, scene_linear.getName())
    cfg.setRole(ocio.ROLE_REFERENCE, aces.getName())
    cfg.setRole(ocio.ROLE_SCENE_LINEAR, scene_linear.getName())

    # add default colorimetry view transform to config
    cfg.addViewTransform(
        ocio.ViewTransform(
            name="colorimetry",
            referenceSpace=ocio.REFERENCE_SPACE_SCENE,
            fromReference=ocio.BuiltinTransform("ACES-AP0_to_CIE-XYZ-D65_BFD"),
        )
    )
    return cfg
def get_display_colorspaces(family=""):
    colour.RGB_COLOURSPACES["CIE-XYZ (D65)"] = colour.RGB_Colourspace(
        name="CIE-XYZ (D65)",
        primaries=np.array([[1.0, 0.0], [0.0, 1.0], [0.0, 0.0]]),
        whitepoint=np.array([0.3127, 0.329]),
        whitepoint_name="D65",
        use_derived_matrix_RGB_to_XYZ=True,
        use_derived_matrix_XYZ_to_RGB=True,
        cctf_decoding=colour.models.linear_function,
        cctf_encoding=colour.models.linear_function,
    )

    xyzd65_to_rec709 = _simplify_transform(
        ocio.GroupTransform(
            [
                ocio.BuiltinTransform(
                    "ACES-AP1_to_CIE-XYZ-D65_BFD", ocio.TRANSFORM_DIR_INVERSE
                ),
                ocio.BuiltinTransform("ACES-AP1_to_LINEAR-REC709_BFD"),
            ]
        )
    )

    # xyzd65_to_rec709 = _convert_numpy_matrix33_to_matrix_transform(
    #     colour.matrix_RGB_to_RGB(
    #         input_colourspace=colour.RGB_COLOURSPACES['CIE-XYZ (D65)'],
    #         output_colourspace=colour.RGB_COLOURSPACES['ITU-R BT.709'],
    #         chromatic_adaptation_transform=None
    #     )
    # )

    xyzd65_to_p3d65 = _convert_numpy_matrix33_to_matrix_transform(
        colour.matrix_RGB_to_RGB(
            input_colourspace=colour.RGB_COLOURSPACES["CIE-XYZ (D65)"],
            output_colourspace=colour.RGB_COLOURSPACES["P3-D65"],
            chromatic_adaptation_transform=None,
        )
    )

    xyzd65_to_p3 = _convert_numpy_matrix33_to_matrix_transform(
        colour.matrix_RGB_to_RGB(
            input_colourspace=colour.RGB_COLOURSPACES["CIE-XYZ (D65)"],
            output_colourspace=colour.RGB_COLOURSPACES["DCI-P3"],
            chromatic_adaptation_transform="Bradford",
        )
    )

    # check
    xyzd65_to_p3_d60_sim_bfd = ocio.GroupTransform(
        [
            ocio.BuiltinTransform(
                "ACES-AP0_to_CIE-XYZ-D65_BFD", ocio.TRANSFORM_DIR_INVERSE
            ),
            _convert_numpy_matrix33_to_matrix_transform(
                colour.matrix_RGB_to_RGB(
                    input_colourspace=colour.RGB_COLOURSPACES["ACES2065-1"],
                    output_colourspace=colour.RGB_COLOURSPACES["DCI-P3"],
                    chromatic_adaptation_transform="Bradford",
                )
            ),
        ]
    )

    # Shapers
    acescct_cctf = ocio.BuiltinTransform("ACEScct-LOG_to_LIN")

    sRGB_g22 = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="sRGB (Gamma ~2.2)",
        description="sRGB (Gamma ~2.2) with Rec.709 primaries",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_rec709,
                display_cctf(
                    gamma=2.4, offset=0.055, direction=ocio.TRANSFORM_DIR_INVERSE
                ),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )

    sRGB = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="sRGB",
        description="sRGB with Rec.709 primaries",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_rec709,
                display_cctf(gamma=2.2, direction=ocio.TRANSFORM_DIR_INVERSE),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )
    Rec709_display = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="Rec.709 (legacy)",
        description="ITU-R BT.709 inverse camera CCTF with BT.709 primaries",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_rec709,
                display_cctf(
                    gamma=1 / 0.45, offset=0.099, direction=ocio.TRANSFORM_DIR_INVERSE
                ),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )

    Rec1886 = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="Rec.1886",
        description="ITU-R BT.1886 with BT.709 primaries and D65 whitepoint",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_rec709,
                display_cctf(gamma=2.4, direction=ocio.TRANSFORM_DIR_INVERSE),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )

    DCI_P3 = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="DCI-P3",
        description="Gamma 2.6 with DCI primaries",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_p3,
                display_cctf(gamma=2.6, direction=ocio.TRANSFORM_DIR_INVERSE),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )

    P3_D65 = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
        name="P3-D65",
        description="Gamma 2.6 with DCI primaries and D65 whitepoint",
        encoding="sdr-video",
        family=family,
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                xyzd65_to_p3d65,
                display_cctf(gamma=2.6, direction=ocio.TRANSFORM_DIR_INVERSE),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )
    # TODO: D60 sim; hdr colorspaces

    return [
        sRGB,
        Rec1886,
        DCI_P3,
        P3_D65,
    ]
Esempio n. 12
0
                'view': 'Raw',
                'colorspace': colorspace_4.getName()
            },
        ],
        active_displays=['sRGB Monitor'],
        active_views=['sRGB - sRGB'],
    )

    generate_config(data, os.path.join(build_directory, 'config-v1.ocio'))

    # "OpenColorIO 2" configuration.
    colorspace_1 = colorspace_factory('ACES - ACES2065-1', 'ACES')
    colorspace_2 = colorspace_factory(
        'ACES - ACEScg',
        'ACES',
        to_reference=ocio.BuiltinTransform('ACEScg_to_ACES2065-1'))
    colorspace_3 = colorspace_factory(
        'Gamut - sRGB',
        'Gamut',
        to_reference=ocio.MatrixTransform([
            0.4387956642, 0.3825367756, 0.1787151431, 0.0000000000,
            0.0890560064, 0.8126211313, 0.0982957371, 0.0000000000,
            0.0173063724, 0.1083658908, 0.8742745984, 0.0000000000,
            0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000,
        ]))  # yapf: disable
    transform = ocio.ExponentWithLinearTransform()
    transform.setGamma([2.4, 2.4, 2.4, 1])
    transform.setOffset([0.055, 0.055, 0.055, 0])
    colorspace_4 = colorspace_factory('CCTF - sRGB',
                                      'CCTF',
                                      to_reference=transform)