bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / thresholding / threshold_multiotsu
function
skimage.filters.thresholding:threshold_multiotsu
source: /dev/scikit-image/src/skimage/filters/thresholding.py :1230
Signature
def threshold_multiotsu ( image = None , classes = 3 , nbins = 256 , * , hist = None ) Summary
Generate classes-1 threshold values to divide gray levels in image, following Otsu's method for multiple classes.
Extended Summary
The threshold values are chosen to maximize the total sum of pairwise variances between the thresholded graylevel classes. See Notes and [1] for more details.
Either image or hist must be provided. If hist is provided, the actual histogram of the image is ignored.
Parameters
image: (M, N[, ...]) ndarray, optionalGrayscale input image.
classes: int, optionalNumber of classes to be thresholded, i.e. the number of resulting regions.
nbins: int, optionalNumber of bins used to calculate the histogram. This value is ignored for integer arrays.
hist: array, or 2-tuple of arrays, optionalHistogram from which to determine the threshold, and optionally a corresponding array of bin center intensities. If no hist provided, this function will compute it from the image (see notes).
Returns
thresh: arrayArray containing the threshold values for the desired classes.
Raises
: ValueErrorIf
imagecontains less grayscale value then the desired number of classes.
Notes
This implementation relies on a Cython function whose complexity is , where is the number of histogram bins and is the number of classes desired.
If no hist is given, this function will make use of skimage.exposure.histogram, which behaves differently than np.histogram. While both allowed, use the former for consistent behaviour.
The input image must be grayscale.
Examples
from skimage.color import label2rgb from skimage import data image = data.camera() thresholds = threshold_multiotsu(image) regions = np.digitize(image, bins=thresholds) regions_colorized = label2rgb(regions)✓
Aliases
-
skimage.filters.threshold_multiotsu