Exemple #1
0
    def test_constructor_with_keyword(self):
        """
        Test ExponentWithLinearTransform constructor with keywords and validate its values.
        """

        # With keywords in their proper order.
        exp_tr = OCIO.ExponentWithLinearTransform(
            gamma=self.TEST_GAMMA,
            offset=self.TEST_OFFSET,
            negativeStyle=self.TEST_NEGATIVE_STYLE,
            direction=self.TEST_DIRECTION)

        self.assertEqual(exp_tr.getGamma(), self.TEST_GAMMA)
        self.assertEqual(exp_tr.getOffset(), self.TEST_OFFSET)
        self.assertEqual(exp_tr.getNegativeStyle(), self.TEST_NEGATIVE_STYLE)
        self.assertEqual(exp_tr.getDirection(), self.TEST_DIRECTION)

        # With keywords not in their proper order.
        exp_tr2 = OCIO.ExponentWithLinearTransform(
            direction=self.TEST_DIRECTION,
            negativeStyle=self.TEST_NEGATIVE_STYLE,
            gamma=self.TEST_GAMMA,
            offset=self.TEST_OFFSET)

        self.assertEqual(exp_tr2.getGamma(), self.TEST_GAMMA)
        self.assertEqual(exp_tr2.getOffset(), self.TEST_OFFSET)
        self.assertEqual(exp_tr2.getNegativeStyle(), self.TEST_NEGATIVE_STYLE)
        self.assertEqual(exp_tr2.getDirection(), self.TEST_DIRECTION)
Exemple #2
0
    def test_constructor_wrong_parameter_type(self):
        """
        Test ExponentWithLinearTransform constructor with a wrong parameter type.
        """

        for invalid in (None, 1, self.TEST_ID):
            with self.assertRaises(TypeError):
                exp_tr = OCIO.ExponentWithLinearTransform(invalid)
Exemple #3
0
    def test_constructor_with_positional(self):
        """
        Test ExponentWithLinearTransform constructor without keywords and validate its values.
        """

        exp_tr = OCIO.ExponentWithLinearTransform(self.TEST_GAMMA,
                                                  self.TEST_OFFSET,
                                                  self.TEST_NEGATIVE_STYLE,
                                                  self.TEST_DIRECTION)

        self.assertEqual(exp_tr.getGamma(), self.TEST_GAMMA)
        self.assertEqual(exp_tr.getOffset(), self.TEST_OFFSET)
        self.assertEqual(exp_tr.getNegativeStyle(), self.TEST_NEGATIVE_STYLE)
        self.assertEqual(exp_tr.getDirection(), self.TEST_DIRECTION)
def display_cctf(gamma=1.0, offset=None, direction=None, negative_style=None):
    if offset:
        cctf = ocio.ExponentWithLinearTransform()
        cctf.setGamma(_rgba_tuple(gamma))
        cctf.setOffset(_rgba_tuple(offset, alpha=0.0))
    else:
        cctf = ocio.ExponentTransform(_rgba_tuple(gamma))

    if direction:
        cctf.setDirection(direction)
    if negative_style:
        cctf.setNegativeStyle(negative_style)

    return cctf
Exemple #5
0
 def setUp(self):
     self.exp_tr = OCIO.ExponentWithLinearTransform()
Exemple #6
0
            },
            {
                'display': 'sRGB Monitor',
                'view': 'Raw',
                'colorspace': 'Utility - Raw'
            },
        ],
        active_displays=['sRGB Monitor'],
        active_views=['sRGB - sRGB'],
    )

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

    # "OpenColorIO 2" configuration.
    data.profile_version = 2
    transform = ocio.ExponentWithLinearTransform()
    transform.setGamma([2.4, 2.4, 2.4, 1])
    transform.setOffset([0.055, 0.055, 0.055, 0])
    data.colorspaces[1].setTransform(transform,
                                     ocio.COLORSPACE_DIR_TO_REFERENCE)
    data.colorspaces[1].setDescription('')

    # TODO: Use new display colorspace system.
    data.views = [
        {
            'display': 'sRGB Monitor',
            'view': 'sRGB - sRGB',
            'colorspace': 'View - sRGB Monitor - sRGB'
        },
        {
            'display': 'sRGB Monitor',
def baby_config():
    linear = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_SCENE,
        name="linear",
        description="scene-linear",
        encoding="scene-linear",
        bitDepth=ocio.BIT_DEPTH_F16,
        # allocation=ocio.ALLOCATION_LG2,
        # allocationVars=[-15, 6]
    )
    sRGB_inv_eotf = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_SCENE,
        name="sRGB (gamma ~2.2)",
        description="sRGB inverse EOTF",
        encoding="sdr-video",
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                ocio.ExponentWithLinearTransform(
                    gamma=[2.4, 2.4, 2.4, 1.0],
                    offset=[0.055, 0.055, 0.055, 0.0],
                    direction=ocio.TRANSFORM_DIR_INVERSE,
                ),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )

    sRGB = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_SCENE,
        name="sRGB",
        description="sRGB inverse EOTF",
        encoding="sdr-video",
        bitDepth=ocio.BIT_DEPTH_UINT10,
        fromReference=ocio.GroupTransform(
            [
                ocio.ExponentTransform(
                    value=[2.2, 2.2, 2.2, 1.0], direction=ocio.TRANSFORM_DIR_INVERSE
                ),
                ocio.RangeTransform(
                    minInValue=0, minOutValue=0, maxInValue=1, maxOutValue=1
                ),
            ]
        ),
    )
    data = ocio.ColorSpace(
        referenceSpace=ocio.REFERENCE_SPACE_SCENE,
        name="non-color data",
        encoding="data",
        isData=True,
    )

    all_colorspaces = [data, linear, sRGB]

    cfg = ocio.Config()
    _ = [cfg.addColorSpace(cs) for cs in all_colorspaces]
    cfg.addColorSpace(linear)
    cfg.addColorSpace(sRGB)

    # Consistently throws problems here likely in relation to the above
    # 412-417 lines being called first and this tripping errors in this
    # block. Commenting seems to quiet the issues.
    # cfg.setRole('aces_interchange', aces.getName())
    # cfg.setRole('cie_xyz_d65_interchange', xyzd65.getName())

    cfg.setRole(ocio.ROLE_DATA, data.getName())
    cfg.setRole(ocio.ROLE_DEFAULT, linear.getName())
    cfg.setRole(ocio.ROLE_REFERENCE, linear.getName())
    cfg.setRole(ocio.ROLE_SCENE_LINEAR, linear.getName())
    cfg.setRole(ocio.ROLE_COLOR_PICKING, sRGB.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'))
    #     )
    # )

    default_display_cs_name = "sRGB"
    cfg.addDisplayView(
        display="sRGB-like Commodity",
        view="Inverse EOTF",
        colorSpaceName=default_display_cs_name,
    )
    # cfg.addSharedView('Colorimetry', 'colorimetry', '<USE_DISPLAY_NAME>')
    # cfg.addDisplaySharedView(default_display, 'Colorimetry')
    return cfg