mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 17:31:50 +08:00
Merge pull request #2118 from local-minimum/patch-1
Fixing Error and documentation on Otsu Threshold
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user