Пример #1
0
    def test_tone(self):
        """
        Test the GradingTone struct creation.
        """

        rgbmB = OCIO.GradingRGBMSW(1, 1, 1, 1, 0.4, 0.4)
        rgbmW = OCIO.GradingRGBMSW(1, 1, 1, 1, 0.4, 0.5)
        rgbmS = OCIO.GradingRGBMSW(1, 1, 1, 1, 0.5, 0)
        rgbmH = OCIO.GradingRGBMSW(1, 1, 1, 1, 0.3, 1)
        rgbmM = OCIO.GradingRGBMSW(1, 1, 1, 1, 0.4, 0.6)
        # Constructor.
        tone = OCIO.GradingTone(OCIO.GRADING_LOG)
        assertEqualRGBMSW(self, rgbmB, tone.blacks)
        assertEqualRGBMSW(self, rgbmW, tone.whites)
        assertEqualRGBMSW(self, rgbmS, tone.shadows)
        assertEqualRGBMSW(self, rgbmH, tone.highlights)
        assertEqualRGBMSW(self, rgbmM, tone.midtones)
        self.assertEqual(1, tone.scontrast)

        with self.assertRaises(AttributeError):
            OCIO.GradingTone(OCIO.TRANSFOR_DIRECTION_FORWARD)

        with self.assertRaises(TypeError):
            OCIO.GradingTone(0)

        newMidtones = OCIO.GradingRGBMSW(1.1, 1.2, 1.3, 1, 0.2, 1.1)
        tone.midtones = newMidtones
        assertEqualRGBM(self, newMidtones, tone.midtones)
Пример #2
0
    def test_rgbm(self):
        """
        Test the GradingRGBM struct.
        """

        # Constructor without parameters.
        rgbm1 = OCIO.GradingRGBM()
        self.assertEqual(0, rgbm1.red)
        self.assertEqual(0, rgbm1.green)
        self.assertEqual(0, rgbm1.blue)
        self.assertEqual(0, rgbm1.master)

        # Constructor with parameters.
        rgbm2 = OCIO.GradingRGBM(1, 2, 3, 4)
        self.assertEqual(1, rgbm2.red)
        self.assertEqual(2, rgbm2.green)
        self.assertEqual(3, rgbm2.blue)
        self.assertEqual(4, rgbm2.master)

        rgbm2.red += 1
        rgbm2.green += 1
        rgbm2.blue += 1
        rgbm2.master += 1
        self.assertEqual(2, rgbm2.red)
        self.assertEqual(3, rgbm2.green)
        self.assertEqual(4, rgbm2.blue)
        self.assertEqual(5, rgbm2.master)

        self.assertNotEqual(rgbm1, rgbm2)
        rgbm1.red = rgbm2.red
        rgbm1.green = rgbm2.green
        rgbm1.blue = rgbm2.blue
        rgbm1.master = rgbm2.master
        assertEqualRGBM(self, rgbm1, rgbm2)

        rgbm1.red += 1
        with self.assertRaises(AssertionError):
            assertEqualRGBM(self, rgbm1, rgbm2)

        rgbm3 = OCIO.GradingRGBM()
        rgbm2 = rgbm3
        self.assertEqual(0, rgbm2.red)
        rgbm3.red = 2
        self.assertEqual(2, rgbm2.red)
        rgbm2.red = 0
        self.assertEqual(0, rgbm3.red)

        with self.assertRaises(TypeError):
            OCIO.GradingRGBM(0)

        with self.assertRaises(TypeError):
            OCIO.GradingRGBM(0, 0)
Пример #3
0
    def test_primary(self):
        """
        Test the GradingPrimary struct.
        """

        rgbm0 = OCIO.GradingRGBM(0, 0, 0, 0)
        rgbm1 = OCIO.GradingRGBM(1, 1, 1, 1)
        # Constructor.
        primaryLog = OCIO.GradingPrimary(OCIO.GRADING_LOG)
        assertEqualRGBM(self, rgbm0, primaryLog.brightness)
        assertEqualRGBM(self, rgbm1, primaryLog.contrast)
        assertEqualRGBM(self, rgbm1, primaryLog.gamma)
        assertEqualRGBM(self, rgbm0, primaryLog.offset)
        assertEqualRGBM(self, rgbm0, primaryLog.exposure)
        assertEqualRGBM(self, rgbm0, primaryLog.lift)
        assertEqualRGBM(self, rgbm1, primaryLog.gain)
        self.assertEqual(-0.2, primaryLog.pivot)
        self.assertEqual(1, primaryLog.saturation)
        # Check that the default values do not clamp.
        self.assertEqual(primaryLog.NoClampWhite, primaryLog.clampWhite)
        self.assertEqual(primaryLog.NoClampBlack, primaryLog.clampBlack)
        self.assertEqual(1, primaryLog.pivotWhite)
        self.assertEqual(0, primaryLog.pivotBlack)

        primaryLin = OCIO.GradingPrimary(OCIO.GRADING_LIN)
        with self.assertRaises(AssertionError):
            assertEqualPrimary(self, primaryLog, primaryLin)

        primaryLog.pivot = 0.18
        assertEqualPrimary(self, primaryLog, primaryLin)

        primaryVideo = OCIO.GradingPrimary(OCIO.GRADING_VIDEO)
        assertEqualPrimary(self, primaryLog, primaryVideo)

        with self.assertRaises(TypeError):
            OCIO.GradingPrimary()

        with self.assertRaises(AttributeError):
            OCIO.GradingPrimary(OCIO.TRANSFOR_DIRECTION_FORWARD)

        with self.assertRaises(TypeError):
            OCIO.GradingPrimary(0)

        newGamma = OCIO.GradingRGBM(1.1, 1.2, 1.3, 1)
        primaryLog.gamma = newGamma
        assertEqualRGBM(self, newGamma, primaryLog.gamma)
Пример #4
0
    def test_rgbmsw(self):
        """
        Test the GradingRGBMSW struct.
        """

        # Constructor without parameters.
        rgbm1 = OCIO.GradingRGBMSW()
        self.assertEqual(1, rgbm1.red)
        self.assertEqual(1, rgbm1.green)
        self.assertEqual(1, rgbm1.blue)
        self.assertEqual(1, rgbm1.master)
        self.assertEqual(0, rgbm1.start)
        self.assertEqual(1, rgbm1.width)

        # Constructor with parameters.
        rgbm2 = OCIO.GradingRGBMSW(1, 2, 3, 4, 5, 6)
        self.assertEqual(1, rgbm2.red)
        self.assertEqual(2, rgbm2.green)
        self.assertEqual(3, rgbm2.blue)
        self.assertEqual(4, rgbm2.master)
        self.assertEqual(5, rgbm2.start)
        self.assertEqual(6, rgbm2.width)

        rgbm2.red += 1
        rgbm2.green += 1
        rgbm2.blue += 1
        rgbm2.master += 1
        rgbm2.start += 1
        rgbm2.width += 1
        self.assertEqual(2, rgbm2.red)
        self.assertEqual(3, rgbm2.green)
        self.assertEqual(4, rgbm2.blue)
        self.assertEqual(5, rgbm2.master)
        self.assertEqual(6, rgbm2.start)
        self.assertEqual(7, rgbm2.width)

        self.assertNotEqual(rgbm1, rgbm2)
        rgbm1.red = rgbm2.red
        rgbm1.green = rgbm2.green
        rgbm1.blue = rgbm2.blue
        rgbm1.master = rgbm2.master
        rgbm1.start = rgbm2.start
        rgbm1.width = rgbm2.width
        assertEqualRGBM(self, rgbm1, rgbm2)

        rgbm1.red += 1
        with self.assertRaises(AssertionError):
            assertEqualRGBMSW(self, rgbm1, rgbm2)

        rgbm3 = OCIO.GradingRGBMSW()
        rgbm2 = rgbm3
        self.assertEqual(1, rgbm2.red)
        rgbm3.red = 2
        self.assertEqual(2, rgbm2.red)
        rgbm2.red = 0
        self.assertEqual(0, rgbm3.red)

        rgbm4 = OCIO.GradingRGBMSW(2, 3)
        self.assertEqual(1, rgbm4.red)
        self.assertEqual(1, rgbm4.green)
        self.assertEqual(1, rgbm4.blue)
        self.assertEqual(1, rgbm4.master)
        self.assertEqual(2, rgbm4.start)
        self.assertEqual(3, rgbm4.width)

        with self.assertRaises(TypeError):
            OCIO.GradingRGBMSW(0)

        with self.assertRaises(TypeError):
            OCIO.GradingRGBMSW(0, 0, 0)