mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-15 11:25:53 +08:00
Raise error when single colored image is passed in threshold_otsu method
This commit is contained in:
@@ -129,6 +129,12 @@ def threshold_otsu(image, nbins=256):
|
||||
"grayscale images; image shape {0} looks like an RGB image"
|
||||
warnings.warn(msg.format(image.shape))
|
||||
|
||||
# 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()))
|
||||
|
||||
hist, bin_centers = histogram(image.ravel(), nbins)
|
||||
hist = hist.astype(float)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user