def test_contructor(self):
        """
        Test GradingRGBCurveTransform constructor without and with keywords.
        """

        gct = OCIO.GradingRGBCurveTransform()
        self.assertEqual(gct.getStyle(), OCIO.GRADING_LOG)
        assertEqualRGBCurve(self, gct.getValue(), self.valDefaultLog)
        self.assertEqual(gct.isDynamic(), False)
        self.assertEqual(gct.getBypassLinToLog(), False)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_FORWARD)

        gct = OCIO.GradingRGBCurveTransform(OCIO.GRADING_LIN)
        self.assertEqual(gct.getStyle(), OCIO.GRADING_LIN)
        assertEqualRGBCurve(self, gct.getValue(), self.valDefaultLin)
        self.assertEqual(gct.isDynamic(), False)
        self.assertEqual(gct.getBypassLinToLog(), False)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_FORWARD)

        vals = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)
        vals.red = OCIO.GradingBSplineCurve(4)
        cpts = vals.red.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(0.0, 0.1)
        cpts[1] = OCIO.GradingControlPoint(0.1, 0.5)
        cpts[2] = OCIO.GradingControlPoint(0.4, 0.6)
        cpts[3] = OCIO.GradingControlPoint(0.6, 0.7)
        gct = OCIO.GradingRGBCurveTransform(style=OCIO.GRADING_VIDEO,
                                            values=vals,
                                            dynamic=True,
                                            dir=OCIO.TRANSFORM_DIR_INVERSE)
        self.assertEqual(gct.getStyle(), OCIO.GRADING_VIDEO)
        self.assertEqual(gct.isDynamic(), True)
        self.assertEqual(gct.getDirection(), OCIO.TRANSFORM_DIR_INVERSE)
        assertEqualRGBCurve(self, gct.getValue(), vals)
Пример #2
0
    def test_rgbcurve(self):
        """
        Test the GradingRGBCurve, creation, default value, modification.
        """

        rgbLin = OCIO.GradingRGBCurve(OCIO.GRADING_LIN)

        defLin = OCIO.GradingBSplineCurve(3)
        cpts = defLin.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(-7, -7)
        cpts[1] = OCIO.GradingControlPoint(0, 0)
        cpts[2] = OCIO.GradingControlPoint(7, 7)
        assertEqualBSpline(self, rgbLin.red, defLin)
        assertEqualBSpline(self, rgbLin.green, defLin)
        assertEqualBSpline(self, rgbLin.blue, defLin)
        assertEqualBSpline(self, rgbLin.master, defLin)

        rgbLog = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)

        defLog = OCIO.GradingBSplineCurve(3)
        cpts = defLog.getControlPoints()
        cpts[0] = OCIO.GradingControlPoint(0, 0)
        cpts[1] = OCIO.GradingControlPoint(0.5, 0.5)
        cpts[2] = OCIO.GradingControlPoint(1, 1)
        assertEqualBSpline(self, rgbLog.red, defLog)
        assertEqualBSpline(self, rgbLog.green, defLog)
        assertEqualBSpline(self, rgbLog.blue, defLog)
        assertEqualBSpline(self, rgbLog.master, defLog)
        with self.assertRaises(AssertionError):
            assertEqualBSpline(self, rgbLog.master, defLin)

        rgbVideo = OCIO.GradingRGBCurve(OCIO.GRADING_LOG)
        assertEqualRGBCurve(self, rgbLog, rgbVideo)
Пример #3
0
    def test_bspline(self):
        """
        Test the GradingBSplineCurve: creation, control point modification, validation.
        """

        bs = OCIO.GradingBSplineCurve(5)
        cpts = bs.getControlPoints()
        # First control point (i.e. cpts[0]) defaults to {0, 0}.
        cpts[1] = OCIO.GradingControlPoint(0.1, 0.5)
        cpts[2] = OCIO.GradingControlPoint(0.4, 0.6)
        cpts[3] = OCIO.GradingControlPoint(0.6, 0.7)
        cpts[4] = OCIO.GradingControlPoint(1, 1)
        self.assertIsNone(bs.validate())

        # Move point 4 before point 3 on the x axis so that the control points are not anymore
        # monotonic. Then, it must throw an exception.
        cpts[4] = OCIO.GradingControlPoint(0.5, 1)
        with self.assertRaises(OCIO.Exception):
            bs.validate()

        # Restore valid data.
        cpts[4] = OCIO.GradingControlPoint(1, 1)

        bs2 = OCIO.GradingBSplineCurve(
            [0, 0, 0.1, 0.5, 0.4, 0.6, 0.6, 0.7, 1, 1])
        cpts2 = bs2.getControlPoints()

        assertEqualBSpline(self, bs, bs2)

        bs3 = OCIO.GradingBSplineCurve(4)
        cpts3 = bs3.getControlPoints()
        cpts3[1] = OCIO.GradingControlPoint(0.1, 0.5)
        cpts3[2] = OCIO.GradingControlPoint(0.4, 0.6)
        cpts3[3] = OCIO.GradingControlPoint(0.6, 0.7)

        with self.assertRaises(AssertionError):
            assertEqualBSpline(self, bs, bs3)

        bs4 = OCIO.GradingBSplineCurve(6)
        cpts4 = bs4.getControlPoints()
        cpts4[1] = OCIO.GradingControlPoint(0.1, 0.5)
        cpts4[2] = OCIO.GradingControlPoint(0.4, 0.6)
        cpts4[3] = OCIO.GradingControlPoint(0.6, 0.7)
        cpts4[4] = OCIO.GradingControlPoint(1, 1)
        cpts4[5] = OCIO.GradingControlPoint(1.2, 1.1)

        with self.assertRaises(AssertionError):
            assertEqualBSpline(self, bs, bs4)

        bs5 = OCIO.GradingBSplineCurve(5)
        cpts5 = bs5.getControlPoints()
        cpts5[1] = OCIO.GradingControlPoint(0.1, 0.5)
        # Different x value.
        cpts5[2] = OCIO.GradingControlPoint(0.5, 0.6)
        cpts5[3] = OCIO.GradingControlPoint(0.6, 0.7)
        cpts5[4] = OCIO.GradingControlPoint(1, 1)

        with self.assertRaises(AssertionError):
            assertEqualBSpline(self, bs, bs5)