
- Scikit Image – Introduction
- Scikit Image - Image Processing
- Scikit Image - Numpy Images
- Scikit Image - Image datatypes
- Scikit Image - Using Plugins
- Scikit Image - Image Handlings
- Scikit Image - Reading Images
- Scikit Image - Writing Images
- Scikit Image - Displaying Images
- Scikit Image - Image Collections
- Scikit Image - Image Stack
- Scikit Image - Multi Image
- Scikit Image - Data Visualization
- Scikit Image - Using Matplotlib
- Scikit Image - Using Ploty
- Scikit Image - Using Mayavi
- Scikit Image - Using Napari
- Scikit Image - Color Manipulation
- Scikit Image - Alpha Channel
- Scikit Image - Conversion b/w Color & Gray Values
- Scikit Image - Conversion b/w RGB & HSV
- Scikit Image - Conversion to CIE-LAB Color Space
- Scikit Image - Conversion from CIE-LAB Color Space
- Scikit Image - Conversion to luv Color Space
- Scikit Image - Conversion from luv Color Space
- Scikit Image - Image Inversion
- Scikit Image - Painting Images with Labels
- Scikit Image - Contrast & Exposure
- Scikit Image - Contrast
- Scikit Image - Contrast enhancement
- Scikit Image - Exposure
- Scikit Image - Histogram Matching
- Scikit Image - Histogram Equalization
- Scikit Image - Local Histogram Equalization
- Scikit Image - Tinting gray-scale images
- Scikit Image - Image Transformation
- Scikit Image - Scaling an image
- Scikit Image - Rotating an Image
- Scikit Image - Warping an Image
- Scikit Image - Affine Transform
- Scikit Image - Piecewise Affine Transform
- Scikit Image - ProjectiveTransform
- Scikit Image - EuclideanTransform
- Scikit Image - Radon Transform
- Scikit Image - Line Hough Transform
- Scikit Image - Probabilistic Hough Transform
- Scikit Image - Circular Hough Transforms
- Scikit Image - Elliptical Hough Transforms
- Scikit Image - Polynomial Transform
- Scikit Image - Image Pyramids
- Scikit Image - Pyramid Gaussian Transform
- Scikit Image - Pyramid Laplacian Transform
- Scikit Image - Swirl Transform
- Scikit Image - Morphological Operations
- Scikit Image - Erosion
- Scikit Image - Dilation
- Scikit Image - Black & White Tophat Morphologies
- Scikit Image - Convex Hull
- Scikit Image - Generating footprints
- Scikit Image - Isotopic Dilation & Erosion
- Scikit Image - Isotopic Closing & Opening of an Image
- Scikit Image - Skelitonizing an Image
- Scikit Image - Morphological Thinning
- Scikit Image - Masking an image
- Scikit Image - Area Closing & Opening of an Image
- Scikit Image - Diameter Closing & Opening of an Image
- Scikit Image - Morphological reconstruction of an Image
- Scikit Image - Finding local Maxima
- Scikit Image - Finding local Minima
- Scikit Image - Removing Small Holes from an Image
- Scikit Image - Removing Small Objects from an Image
- Scikit Image - Filters
- Scikit Image - Image Filters
- Scikit Image - Median Filter
- Scikit Image - Mean Filters
- Scikit Image - Morphological gray-level Filters
- Scikit Image - Gabor Filter
- Scikit Image - Gaussian Filter
- Scikit Image - Butterworth Filter
- Scikit Image - Frangi Filter
- Scikit Image - Hessian Filter
- Scikit Image - Meijering Neuriteness Filter
- Scikit Image - Sato Filter
- Scikit Image - Sobel Filter
- Scikit Image - Farid Filter
- Scikit Image - Scharr Filter
- Scikit Image - Unsharp Mask Filter
- Scikit Image - Roberts Cross Operator
- Scikit Image - Lapalace Operator
- Scikit Image - Window Functions With Images
- Scikit Image - Thresholding
- Scikit Image - Applying Threshold
- Scikit Image - Otsu Thresholding
- Scikit Image - Local thresholding
- Scikit Image - Hysteresis Thresholding
- Scikit Image - Li thresholding
- Scikit Image - Multi-Otsu Thresholding
- Scikit Image - Niblack and Sauvola Thresholding
- Scikit Image - Restoring Images
- Scikit Image - Rolling-ball Algorithm
- Scikit Image - Denoising an Image
- Scikit Image - Wavelet Denoising
- Scikit Image - Non-local means denoising for preserving textures
- Scikit Image - Calibrating Denoisers Using J-Invariance
- Scikit Image - Total Variation Denoising
- Scikit Image - Shift-invariant wavelet denoising
- Scikit Image - Image Deconvolution
- Scikit Image - Richardson-Lucy Deconvolution
- Scikit Image - Recover the original from a wrapped phase image
- Scikit Image - Image Inpainting
- Scikit Image - Registering Images
- Scikit Image - Image Registration
- Scikit Image - Masked Normalized Cross-Correlation
- Scikit Image - Registration using optical flow
- Scikit Image - Assemble images with simple image stitching
- Scikit Image - Registration using Polar and Log-Polar
- Scikit Image - Feature Detection
- Scikit Image - Dense DAISY Feature Description
- Scikit Image - Histogram of Oriented Gradients
- Scikit Image - Template Matching
- Scikit Image - CENSURE Feature Detector
- Scikit Image - BRIEF Binary Descriptor
- Scikit Image - SIFT Feature Detector and Descriptor Extractor
- Scikit Image - GLCM Texture Features
- Scikit Image - Shape Index
- Scikit Image - Sliding Window Histogram
- Scikit Image - Finding Contour
- Scikit Image - Texture Classification Using Local Binary Pattern
- Scikit Image - Texture Classification Using Multi-Block Local Binary Pattern
- Scikit Image - Active Contour Model
- Scikit Image - Canny Edge Detection
- Scikit Image - Marching Cubes
- Scikit Image - Foerstner Corner Detection
- Scikit Image - Harris Corner Detection
- Scikit Image - Extracting FAST Corners
- Scikit Image - Shi-Tomasi Corner Detection
- Scikit Image - Haar Like Feature Detection
- Scikit Image - Haar Feature detection of coordinates
- Scikit Image - Hessian matrix
- Scikit Image - ORB feature Detection
- Scikit Image - Additional Concepts
- Scikit Image - Render text onto an image
- Scikit Image - Face detection using a cascade classifier
- Scikit Image - Face classification using Haar-like feature descriptor
- Scikit Image - Visual image comparison
- Scikit Image - Exploring Region Properties With Pandas
Scikit image − Multi-Otsu Thresholding
Multi-Otsu Thresholding is an algorithm used to categorize the pixels within an image into several different classes based on their gray-level intensities. It calculates multiple thresholds based on the desired number of classes. If the desired number of classes is three then the resulting threshold values will be two.
The scikit image library provides a function called threshold_multiotsu() within its filters module to separate the pixels of a grayscale image into several different classes.
Using the skimage.filters.threshold_multiotsu() function
This function generates class-1 threshold values to divide the gray levels in an image into multiple classes, using Otsu's method for multiple classes. The thresholds are selected to maximize the total sum of pairwise variances between the thresholded gray-level classes.
It requires either the image or hist parameter to be provided. If hist is provided, it uses the provided histogram to determine the thresholds. If the image is provided, it computes the histogram from the image.
Syntax
Following is the syntax of this function −
skimage.filters.threshold_multiotsu(image=None, classes=3, nbins=256, *, hist=None)
Parameters
The function accepts the following parameters −
- Image (N, M[, â¦, P]) ndarray: An optional grayscale input image.
- Classes (int): An optional integer specifying the number of classes to be thresholded, i.e., the number of resulting regions.
- nbins (int): An optional integer specifying the number of bins used to calculate the histogram. This value is ignored for integer arrays.
- hist (array, or 2-tuple of arrays): An optional input histogram from which to determine the threshold, and optionally, a corresponding array of bin center intensities. If no histogram is provided, the function will compute it from the image.
Return value
The function returns an array containing the threshold values for the desired classes. Additionally, the function can raise a ValueError if the input image contains fewer grayscale values than the desired number of classes.
Example
The following example demonstrates how to perform multi-level thresholding using Otsu's method on a grayscale image using the threshold_multiotsu() function and then colorize the regions using the label2rgb() function −
import numpy as np import matplotlib.pyplot as plt from skimage.color import label2rgb, rgb2gray from skimage.filters import threshold_multiotsu from skimage import io, color # Load the input image image = rgb2gray(io.imread('Images/python logo2.jpg')) # Calculate multi-Otsu thresholds using the threshold_multiotsu function # Generating three classes by default thresholds = threshold_multiotsu(image) # Digitize the image into regions based on the calculated thresholds regions = np.digitize(image, bins=thresholds) # Colorize the regions for visualization regions_colorized = label2rgb(regions) # Plot the original image and the result fig, axes = plt.subplots(1, 2, figsize=(15, 5)) ax = axes.ravel() # Display the Original Image ax[0].imshow(image, cmap='gray') ax[0].set_title('Original Image') ax[0].axis('off') # Display the colorized regions ax[1].imshow(regions_colorized) ax[1].set_title('Colorized regions') ax[1].axis('off') plt.tight_layout() plt.show()
Output
Example
The following example applies the Multi-Otsu thresholding algorithm to a grayscale image to segment it into "5" regions by setting classes=5 −
import matplotlib.pyplot as plt import numpy as np from skimage import io, color from skimage.filters import threshold_multiotsu # Load the grayscale image image = color.rgb2gray(io.imread('Images/group chat.jpg')) # Calculate multi-Otsu thresholds, and generate 5 classes by specifying classes=5 thresholds = threshold_multiotsu(image, classes=5) # Digitize the image into 5 regions based on the calculated thresholds. regions = np.digitize(image, bins=thresholds) # Create subplots for original image, histogram, and Multi-Otsu result. fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(12, 4)) # Plot the original grayscale image. ax[0].imshow(image, cmap='gray') ax[0].set_title('Original') ax[0].axis('off') # Plot the histogram and mark the four thresholds obtained from multi-Otsu. ax[1].hist(image.ravel(), bins=255) ax[1].set_title('Histogram') for thresh in thresholds: ax[1].axvline(thresh, color='r') # Plot the Multi-Otsu result with color mapping. ax[2].imshow(regions, cmap='jet') ax[2].set_title('Multi-Otsu result') ax[2].axis('off') plt.subplots_adjust() plt.show()