What is multi-Otsu thresholding?

Multi-Otsu thresholding is an extension of Otsu’s thresholding method, which is used to segment an image into multiple classes or regions based on pixel intensity values. While Otsu’s method finds a single threshold to divide the image into two classes (typically foreground and background), multi-Otsu thresholding extends this to divide the image into more than two classes or regions, effectively segmenting the image into multiple levels of intensity. This is particularly useful when we have an image with multiple objects or regions with distinct intensity levels.

In multi-Otsu thresholding, the image is divided into kk classes, where kk is a user-specified parameter. The algorithm iteratively searches for k1k-1 thresholds that maximize the variance between the classes, leading to the best separation of intensity levels. Each threshold separates the image into two classes, and this process is repeated until kk classes are obtained. The threshold values determine the intensity ranges for each class.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

The threshold_multiotsu() method

The syntax of the threshold_multiotsu() method is given below:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

In Skimage, the threshold_multiotsu() method takes 4 parameters:

  • image: The first parameter is a grayscale input image.

  • classes: The second parameter is the number of kk classes to be thresholded. The default value of these classes is 3. This is an optional parameter.

  • nbins: The third parameter is the number of bins used to calculate the histogram. This is also an optional parameter.

  • hist: The fourth parameter is the histogram from which to determine the threshold. If no hist is provided, then this function computes it from the image. This is also an optional parameter.

Note: The threshold_multiotsu() method only takes a grayscale image. If we have a color image, then we convert it to grayscale using the rgb2gray() method before applying the multi thresholding algorithm.

Let’s understand multi-Otsu thresholding with the help of the following examples.

Example with 3 classes

In the following example, we use three classes, which means the input image is thresholded into three classes:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Code explanation

  • Lines 1–6: We import the required libraries.

  • Line 9: We load a camera image that is available in Skimage.

  • Line 13: We generate thresholds using the threshold_multiotsu() method and assign the thresholds to the thresholdValues variable.

  • Line 15: We generate a number of regions based on the thresholdValues and assign them to the number OfRegions variable.

  • Lines 1834: We display the original image, a histogram of the original image (with 3 classes), and the thresholded image.

Example with 4 classes

In the following example, we use four classes, which means the input image is thresholded into four classes:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Code explanation

  • Lines 1–6: We import the required libraries.

  • Line 9: We load a camera image that is available in Skimage.

  • Line 13: We generate thresholds using the threshold_multiotsu() method and assign the thresholds to the thresholdValues variable.

  • Line 15: We generate a number of regions based on the thresholdValues and assign them to the number OfRegions variable.

  • Lines 18–34: We display the original image, a histogram of the original image (with 4 classes), and the thresholded image.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved