Merge pull request #2118 from local-minimum/patch-1

Fixing Error and documentation on Otsu Threshold
This commit is contained in:
Juan Nunez-Iglesias
2016-06-01 17:18:19 +10:00
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -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())
+8 -3
View File
@@ -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)