diff --git a/skimage/filters/tests/test_thresholding.py b/skimage/filters/tests/test_thresholding.py index 03557caf..c5d583b2 100644 --- a/skimage/filters/tests/test_thresholding.py +++ b/skimage/filters/tests/test_thresholding.py @@ -167,7 +167,7 @@ def test_otsu_astro_image(): def test_otsu_one_color_image(): img = np.ones((10, 10), dtype=np.uint8) - assert_raises(TypeError, threshold_otsu, img) + assert_raises(ValueError, threshold_otsu, img) def test_li_camera_image(): camera = skimage.img_as_ubyte(data.camera()) diff --git a/skimage/filters/thresholding.py b/skimage/filters/thresholding.py index 331ea3f4..2f9023d6 100644 --- a/skimage/filters/thresholding.py +++ b/skimage/filters/thresholding.py @@ -110,6 +110,11 @@ def threshold_otsu(image, nbins=256): threshold : float Upper threshold value. All pixels intensities that less or equal of this value assumed as foreground. + + Raises + ------ + ValueError + If `image` only contains a single grayscale value. References ---------- @@ -133,9 +138,9 @@ def threshold_otsu(image, nbins=256): # Check if the image is multi-colored or not if image.min() == image.max(): - raise TypeError("threshold_otsu is expected to work with images " \ - "having more than one color. The input image seems " \ - "to have just one color {0}.".format(image.min())) + raise ValueError("threshold_otsu is expected to work with images " \ + "having more than one color. The input image seems " \ + "to have just one color {0}.".format(image.min())) hist, bin_centers = histogram(image.ravel(), nbins) hist = hist.astype(float)