コード例 #1
0
ファイル: test_imagemorph.py プロジェクト: z411/Pillow
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)
コード例 #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)
コード例 #3
0
ファイル: test_imagemorph.py プロジェクト: hugovk/Pillow
    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)
コード例 #4
0
ファイル: ImageMorph.py プロジェクト: roarior/Pillow
    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)
コード例 #5
0
ファイル: ImageMorph.py プロジェクト: Perkville/Pillow
    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)
コード例 #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)