mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 02:46:18 +03:00
Merge pull request #5414 from radarhere/morph
Changed ImageMorph incorrect mode errors to ValueError
This commit is contained in:
commit
b09a9210d4
|
@ -235,19 +235,19 @@ def test_negate():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_non_binary_images():
|
def test_incorrect_mode():
|
||||||
im = hopper("RGB")
|
im = hopper("RGB")
|
||||||
mop = ImageMorph.MorphOp(op_name="erosion8")
|
mop = ImageMorph.MorphOp(op_name="erosion8")
|
||||||
|
|
||||||
with pytest.raises(Exception) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
mop.apply(im)
|
mop.apply(im)
|
||||||
assert str(e.value) == "Image must be binary, meaning it must use mode L"
|
assert str(e.value) == "Image mode must be L"
|
||||||
with pytest.raises(Exception) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
mop.match(im)
|
mop.match(im)
|
||||||
assert str(e.value) == "Image must be binary, meaning it must use mode L"
|
assert str(e.value) == "Image mode must be L"
|
||||||
with pytest.raises(Exception) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
mop.get_on_pixels(im)
|
mop.get_on_pixels(im)
|
||||||
assert str(e.value) == "Image must be binary, meaning it must use mode L"
|
assert str(e.value) == "Image mode must be L"
|
||||||
|
|
||||||
|
|
||||||
def test_add_patterns():
|
def test_add_patterns():
|
||||||
|
|
|
@ -196,7 +196,7 @@ class MorphOp:
|
||||||
raise Exception("No operator loaded")
|
raise Exception("No operator loaded")
|
||||||
|
|
||||||
if image.mode != "L":
|
if image.mode != "L":
|
||||||
raise Exception("Image must be binary, meaning it must use mode L")
|
raise ValueError("Image mode must be L")
|
||||||
outimage = Image.new(image.mode, image.size, None)
|
outimage = Image.new(image.mode, image.size, None)
|
||||||
count = _imagingmorph.apply(bytes(self.lut), image.im.id, outimage.im.id)
|
count = _imagingmorph.apply(bytes(self.lut), image.im.id, outimage.im.id)
|
||||||
return count, outimage
|
return count, outimage
|
||||||
|
@ -211,7 +211,7 @@ class MorphOp:
|
||||||
raise Exception("No operator loaded")
|
raise Exception("No operator loaded")
|
||||||
|
|
||||||
if image.mode != "L":
|
if image.mode != "L":
|
||||||
raise Exception("Image must be binary, meaning it must use mode L")
|
raise ValueError("Image mode must be L")
|
||||||
return _imagingmorph.match(bytes(self.lut), image.im.id)
|
return _imagingmorph.match(bytes(self.lut), image.im.id)
|
||||||
|
|
||||||
def get_on_pixels(self, image):
|
def get_on_pixels(self, image):
|
||||||
|
@ -221,7 +221,7 @@ class MorphOp:
|
||||||
of all matching pixels. See :ref:`coordinate-system`."""
|
of all matching pixels. See :ref:`coordinate-system`."""
|
||||||
|
|
||||||
if image.mode != "L":
|
if image.mode != "L":
|
||||||
raise Exception("Image must be binary, meaning it must use mode L")
|
raise ValueError("Image mode must be L")
|
||||||
return _imagingmorph.get_on_pixels(image.im.id)
|
return _imagingmorph.get_on_pixels(image.im.id)
|
||||||
|
|
||||||
def load_lut(self, filename):
|
def load_lut(self, filename):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user