Esempio n. 1
0
    def _derotationTest(self, imageName):
        image = samples.getSample("algorithmTests", imageName)[0]
        inverted = ImageOps.invert(image.convert("L"))
        before = derotate._getAngle(inverted)

        derotated = derotate.derotate(image)
        invertedDerotated = ImageOps.invert(derotated)
        after = derotate._getAngle(invertedDerotated)

        self.assertLessEqual(abs(after), abs(before))
        self.assertLessEqual(abs(after), 10.0)
Esempio n. 2
0
    def _derotationTest(self, imageName):
        image = samples.getSample("algorithmTests", imageName)[0]
        inverted = ImageOps.invert(image.convert("L"))
        before = derotate._getAngle(inverted)

        derotated = derotate.derotate(image)
        invertedDerotated = ImageOps.invert(derotated)
        after = derotate._getAngle(invertedDerotated)

        self.assertLessEqual(abs(after), abs(before))
        self.assertLessEqual(abs(after), 10.0)
Esempio n. 3
0
    def test_simple(self):
        """
        Tests the destriping algorithm on a simple image with thick borders
        and a dot in the middle. The borders are red, green, blue and yellow,
        the dot is black and the remaining area is white. The result should
        be a white picture with the dot in the middle remaining.
        """
        image, solution = samples.getSample("algorithmTests", "border.gif")
        self.assertEqual(len(tools.getColors(image)), 6)

        destriped = destripe.destripe(image)
        destripedColors = tools.getColors(destriped)
        self.assertEqual(len(destripedColors), 2)
        WHITE, BLACK = (255, 255, 255), (0, 0, 0)
        self.assertEqual(destripedColors, set([WHITE, BLACK]))

        width, height = image.size
        dotPixel = image.getpixel((width // 2, height // 2))
        self.assertEqual(dotPixel, BLACK)
Esempio n. 4
0
    def test_simple(self):
        """
        Tests the destriping algorithm on a simple image with thick borders
        and a dot in the middle. The borders are red, green, blue and yellow,
        the dot is black and the remaining area is white. The result should
        be a white picture with the dot in the middle remaining.
        """
        image, solution = samples.getSample("algorithmTests", "border.gif")
        self.assertEqual(len(tools.getColors(image)), 6)

        destriped = destripe.destripe(image)
        destripedColors = tools.getColors(destriped)
        self.assertEqual(len(destripedColors), 2)
        WHITE, BLACK = (255, 255, 255), (0, 0, 0)
        self.assertEqual(destripedColors, set([WHITE, BLACK]))

        width, height = image.size
        dotPixel = image.getpixel((width // 2, height // 2))
        self.assertEqual(dotPixel, BLACK)
Esempio n. 5
0
 def test_simple(self):
     image, solution = samples.getSample("algorithmTests",
                                         "segmentable.gif")
     segments = segment.segment(image)
     self.assertEqual(len(segments), 2)
Esempio n. 6
0
 def test_simple(self):
     image, solution = samples.getSample("algorithmTests", "segmentable.gif")
     segments = segment.segment(image)
     self.assertEqual(len(segments), 2)