Example #1
0
def test_wrong_mode():
    lut = ImageMorph.LutBuilder(op_name="corner").build_lut()
    imrgb = Image.new("RGB", (10, 10))
    iml = Image.new("L", (10, 10))

    with pytest.raises(RuntimeError):
        _imagingmorph.apply(bytes(lut), imrgb.im.id, iml.im.id)

    with pytest.raises(RuntimeError):
        _imagingmorph.apply(bytes(lut), iml.im.id, imrgb.im.id)

    with pytest.raises(RuntimeError):
        _imagingmorph.match(bytes(lut), imrgb.im.id)

    # Should not raise
    _imagingmorph.match(bytes(lut), iml.im.id)
Example #2
0
    def test_wrong_mode(self):
        lut = ImageMorph.LutBuilder(op_name='corner').build_lut()
        imrgb = Image.new('RGB', (10, 10))
        iml = Image.new('L', (10, 10))

        with self.assertRaises(RuntimeError):
            _imagingmorph.apply(bytes(lut), imrgb.im.id, iml.im.id)

        with self.assertRaises(RuntimeError):
            _imagingmorph.apply(bytes(lut), iml.im.id, imrgb.im.id)

        with self.assertRaises(RuntimeError):
            _imagingmorph.match(bytes(lut), imrgb.im.id)

        # Should not raise
        _imagingmorph.match(bytes(lut), iml.im.id)
Example #3
0
    def test_wrong_mode(self):
        lut = ImageMorph.LutBuilder(op_name='corner').build_lut()
        imrgb = Image.new('RGB', (10, 10))
        iml = Image.new('L', (10, 10))

        with self.assertRaises(RuntimeError):
            _imagingmorph.apply(bytes(lut), imrgb.im.id, iml.im.id)

        with self.assertRaises(RuntimeError):
            _imagingmorph.apply(bytes(lut), iml.im.id, imrgb.im.id)

        with self.assertRaises(RuntimeError):
            _imagingmorph.match(bytes(lut), imrgb.im.id)

        # Should not raise
        _imagingmorph.match(bytes(lut), iml.im.id)
Example #4
0
    def match(self, image):
        """Get a list of coordinates matching the morphological operation on
        an image.

        Returns a list of tuples of (x,y) coordinates
        of all matching pixels."""
        if self.lut is None:
            raise Exception('No operator loaded')

        return _imagingmorph.match(bytes(self.lut), image.im.id)
Example #5
0
    def match(self, image):
        """Get a list of coordinates matching the morphological operation on
        an image.

        Returns a list of tuples of (x,y) coordinates
        of all matching pixels."""
        if self.lut is None:
            raise Exception("No operator loaded")

        if image.mode != "L":
            raise Exception("Image must be binary, meaning it must use mode L")
        return _imagingmorph.match(bytes(self.lut), image.im.id)
Example #6
0
    def match(self, image):
        """Get a list of coordinates matching the morphological operation on
        an image.

        Returns a list of tuples of (x,y) coordinates
        of all matching pixels."""
        if self.lut is None:
            raise Exception('No operator loaded')

        if image.mode != 'L':
            raise Exception('Image must be binary, meaning it must use mode L')
            return
        return _imagingmorph.match(bytes(self.lut), image.im.id)