Fact-checked by Grok 2 weeks ago

Otsu's method

Otsu's method is a nonparametric and technique in for automatically selecting an optimal from a image's to segment the image into foreground and background classes. By treating the pixels as two groups separated by the , it maximizes the between-class variance—or equivalently, minimizes the within-class variance—using only the zeroth- and first-order cumulative moments of the , thereby achieving effective binarization without requiring prior knowledge of the image content. Developed by Nobuyuki Otsu, a researcher in pattern recognition and image processing, the method was first proposed in 1979 in the paper titled A Threshold Selection Method from Gray-Level Histograms, published in IEEE Transactions on Systems, Man, and Cybernetics. This work addressed the challenges of manual thresholding, such as difficulties in detecting histogram valleys due to noise, uneven illumination, or non-bimodal distributions, by applying discriminant analysis to evaluate threshold quality directly from histogram data. The algorithm assumes a bimodal histogram representing two distinct classes and operates iteratively over possible gray-level values (typically 0 to 255 for 8-bit images) to compute class probabilities w_0(k) and w_1(k), means \mu_0(k) and \mu_1(k), and the between-class variance \sigma_B^2(k) = w_0(k) w_1(k) [\mu_0(k) - \mu_1(k)]^2, selecting the threshold k that yields the maximum \sigma_B^2. Otsu's method is computationally efficient, with a time complexity of O(L) where L is the number of gray levels, making it suitable for applications, though extensions to multilevel thresholding (for more than two classes) increase complexity to O(L^m) for m thresholds. It has been widely adopted in for tasks including document binarization, in , and preprocessing in , and remains a benchmark for histogram-based segmentation despite limitations in handling complex or non-uniform lighting, often addressed by approaches.

Introduction

Overview

Otsu's method is a histogram-based image processing technique designed to automatically determine an optimal for separating foreground objects from the background in images. It operates by treating pixels as belonging to two classes—foreground and background—and selects the threshold value that maximizes the between-class variance, thereby achieving the best possible separation between these classes. This and nonparametric approach makes it particularly suitable for applications in , where manual threshold selection would be impractical or subjective. The input to Otsu's method is the histogram of the , which represents the of values ranging from 0 to 255 (or the maximum gray level L). The output is a single threshold value T, which can then be applied to binarize the : pixels with intensities less than or equal to T are classified as background (typically set to 0), while those greater than T are classified as foreground (set to 1 or the maximum intensity). This binarization facilitates subsequent tasks such as and analysis in fields like and . Conceptually, the workflow involves computing the image's , then iteratively evaluating possible values within the range of gray levels. For each candidate , the method assesses the separation between the two resulting classes and identifies the one that yields the maximum inter-class variance, ensuring the lies in a position that distinctly partitions the pixel populations. thresholding, as enabled by this method, serves as a foundational step in broader segmentation processes. The method performs especially well on images with bimodal histograms, where the intensity distribution exhibits two prominent peaks corresponding to the background and foreground regions. In such cases, the optimal threshold is qualitatively selected near the valley between the peaks, effectively isolating the modes and minimizing overlap between classes for clear segmentation.

History

Otsu's method was proposed by Nobuyuki Otsu, a researcher at the Electrotechnical Laboratory in , in his 1979 paper titled "A Threshold Selection Method from Gray-Level Histograms," published in IEEE Transactions on Systems, Man, and Cybernetics. The work introduced an automated, nonparametric technique for selecting thresholds in images based on analysis, aiming to separate pixels into foreground and background classes by maximizing inter-class variance. The method emerged amid the burgeoning field of in the late 1970s, a period marked by the advent of affordable hardware and the growing application of computers to , particularly in such as computed tomography (CT) scans. Prior approaches to image thresholding often relied on manual selection or required assumptions about image content, which proved limiting in early systems where automation was increasingly demanded to handle complex, real-world imagery. Otsu's innovation addressed these constraints by providing a fully that operated solely on the image's intensity histogram, without needing prior knowledge of the scene. Upon publication, the method gained rapid acceptance in the image processing community due to its simplicity, computational efficiency—requiring only a single pass over the histogram—and robustness for bimodal distributions common in many grayscale images. It became a standard reference for thresholding techniques, with early citations appearing in subsequent works on pattern recognition and computer vision by the early 1980s, reflecting its utility in overcoming the subjectivity of manual methods. Key milestones in the method's evolution include its integration into major software libraries during the 2000s, such as , where it was implemented as a core thresholding function to support real-time applications in . The core algorithm has remained unchanged since its inception, underscoring its enduring effectiveness, though post-2010 developments have seen it incorporated as a preprocessing step in pipelines, such as for segmenting regions of interest in prior to classification tasks.

Background Concepts

Image Thresholding

Image thresholding is a fundamental technique in used to convert a into a , thereby segmenting it into foreground and background regions based on values. This method assigns each to one of two classes: with values greater than or equal to a threshold T are classified as foreground (typically assigned a value of 1), while those below T are classified as background (assigned 0). The basic formulation for the binarized output g(x,y) from the input f(x,y) is given by: g(x,y) = \begin{cases} 1 & \text{if } f(x,y) \geq T \\ 0 & \text{otherwise} \end{cases} This process effectively reduces the image's intensity resolution from 256 possible gray levels to just two discrete classes, simplifying the data for further computational analysis. The primary purpose of image thresholding is to facilitate image segmentation, which isolates objects or regions of interest from the background to enable higher-level tasks such as object detection, edge finding, and feature extraction in applications like medical imaging, document analysis, and computer vision. By creating a clear distinction between relevant and irrelevant pixels, thresholding enhances the interpretability of images and reduces computational complexity in subsequent processing steps. For instance, in biomedical contexts, it can delineate cells or tissues from surrounding areas, aiding in automated diagnosis. Thresholding methods are broadly categorized into global and local (adaptive) types. Global thresholding applies a single, uniform T across the entire , making it suitable for scenes with consistent but less effective for with varying . In , local thresholding computes a distinct T for smaller regions or windows within the , adapting to spatial variations in such as shadows or highlights; however, this approach is computationally more intensive. Global methods form the basis for many automated segmentation pipelines due to their and . A key challenge in image thresholding lies in selecting an optimal threshold T, as manual determination—often by —is subjective, time-consuming, and prone to inconsistency, particularly for large datasets or complex images with non-uniform distributions. This subjectivity can lead to over- or under-segmentation, especially in noisy environments or under varying lighting conditions, where a fixed T may fail to capture true boundaries. Automated methods, such as Otsu's method, address this by deriving T objectively from image properties like histograms, which represent value distributions and guide placement.

Histogram and Probability Distributions

In grayscale images, the histogram is defined as a discrete function h(r_k) that represents the number of pixels with a specific gray level r_k, where k ranges from 0 to L-1 and L is the number of gray levels, typically 256 for 8-bit images. This histogram provides a graphical representation of the intensity distribution across the image, capturing the frequency of each gray value. To analyze the image statistically, the is normalized to obtain a p(r_k) = \frac{h(r_k)}{N}, where N is the total number of pixels in the . This assumes a uniform spatial distribution of pixels and transforms the into an estimate of the of gray levels, enabling probabilistic interpretations essential for segmentation tasks. Otsu's method relies on the assumption of a bimodal histogram, characterized by two prominent peaks that typically correspond to the and foreground regions, making threshold selection more straightforward. In contrast, unimodal histograms (with a single peak) or ones (with multiple peaks) can pose challenges for thresholding by obscuring clear separations. Cumulative distributions derived from the are crucial for deriving class statistics, such as the background w_b(T) = \sum_{k=0}^{T} p(r_k) and the background \mu_b(T) = \frac{\sum_{k=0}^{T} k \cdot p(r_k)}{w_b(T)}, where T is a potential level. These s facilitate efficient computation of means and weights without recalculating full sums for each threshold. The underlying assumptions include modeling the as a mixture of two distributions for the pixel classes—often Gaussian mixtures to represent foreground and —though the method remains distribution-agnostic as a nonparametric technique. These histograms and distributions form the foundational input for image thresholding approaches.

Core Algorithm

Mathematical Formulation

Otsu's method involves bipartitioning the pixels of a into two es based on an intensity threshold T, where 0 (background) consists of s with gray levels from 0 to T, and 1 (foreground) consists of s with gray levels from T+1 to L-1, with L denoting the total number of gray levels. The probability of a belonging to 0 is given by the cumulative probability w_0(T) = \sum_{k=0}^{T} p(r_k), where p(r_k) is the probability of gray level r_k, and the probability for 1 is w_1(T) = 1 - w_0(T). The mean intensity of class 0 is \mu_0(T) = \frac{\sum_{k=0}^{T} k p(r_k)}{w_0(T)}, while the mean of class 1 is computed as \mu_1(T) = \frac{\mu_T - \mu_0(T) w_0(T)}{w_1(T)}, where \mu_T = \sum_{k=0}^{L-1} k p(r_k) is the total intensity of the . The method maximizes the between-class variance to achieve optimal separability, defined as \sigma_b^2(T) = w_0(T) (\mu_0(T) - \mu_T)^2 + w_1(T) (\mu_1(T) - \mu_T)^2, which is equivalently expressed as \sigma_b^2(T) = w_0(T) w_1(T) [\mu_0(T) - \mu_1(T)]^2. The within-class variance is \sigma_w^2(T) = w_0(T) \sigma_0^2(T) + w_1(T) \sigma_1^2(T), where \sigma_0^2(T) and \sigma_1^2(T) are the variances of the individual classes. The total variance \sigma^2 remains constant for all thresholds and satisfies the relation \sigma^2 = \sigma_b^2(T) + \sigma_w^2(T), such that maximizing \sigma_b^2(T) is equivalent to minimizing \sigma_w^2(T). The optimal threshold is thus selected as T^* = \arg\max_T \sigma_b^2(T).

Computational Steps

The computational steps of Otsu's method involve processing the gray-level histogram of an image to determine the optimal threshold that maximizes the between-class variance. Assuming an 8-bit grayscale image with L=256 possible intensity levels (denoted as r_k for k=0 to 255), the procedure begins by computing the normalized histogram to obtain the probability distribution p(r_k) for each level k. This is done by counting the number of pixels at each gray level h(r_k) and dividing by the total number of pixels N, yielding p(r_k) = h(r_k)/N, which represents the probability mass function of the image's intensity distribution. Next, the total mean intensity μ_T of the image is calculated as the weighted sum μ_T = ∑_{k=0}^{L-1} k · p(r_k), providing a reference for subsequent mean computations. This step ensures all further calculations are anchored to the overall image statistics. To efficiently evaluate potential s without recomputing sums from scratch for each candidate, an incremental approach is used. Initialize the background parameters as w_0 = 0 and μ_0 = 0. Then, iterate over possible threshold values T from 1 to L-1: update the background weight w_0 by adding p(r_{T-1}), and recursively update the background mean μ_0 using the formula μ_0 = (μ_0 · w_0^{old} + (T-1) · p(r_{T-1})) / w_0, where w_0^{old} is the previous weight value. This avoids the need for full summations at each iteration, enabling linear-time processing. For each candidate threshold T, compute the foreground parameters as w_1 = 1 - w_0 and μ_1 = (μ_T - w_0 · μ_0) / w_1. The between-class variance is then σ_b²(T) = w_0 · w_1 · (μ_0 - μ_1)², which serves as the discriminant criterion. Track the value of T that yields the maximum σ_b²(T) across all iterations; this T* becomes the optimal . The method assumes a bimodal histogram for optimal performance, but in cases of distributions, it may select a suboptimal while remaining computationally efficient, with a of O(L) due to the incremental updates—highly practical for standard L=256. Once T* is found, pixels with below T* are assigned to the background class, and those at or above to the foreground, completing the binarization.

Implementations

Pseudocode

The pseudocode for Otsu's method provides a clear, language-independent of the , assuming an 8-bit with 256 intensity levels (0 to 255) and a precomputed . It initializes the histogram, normalizes it to probabilities, computes the total , and iteratively calculates between-class variance to find the optimal that maximizes it. This formulation, derived from the original , employs incremental updates to cumulative sums for efficiency.
algorithm OtsuThreshold(image)
    // Input: grayscale image
    // Output: optimal threshold T*

    N ← number of pixels in image
    hist[0..255] ← histogram of image intensities  // hist[k] = count of pixels with intensity k

    for k = 0 to 255
        p[k] ← hist[k] / N  // probability distribution

    μ_T ← 0
    for k = 0 to 255
        μ_T ← μ_T + k * p[k]  // total mean intensity

    w0 ← p[0]
    mu0 ← 0
    max_var ← 0
    threshold ← 0

    for T = 1 to 255
        w0 ← w0 + p[T]
        if w0 == 0 or w0 == 1
            continue  // skip edge cases where a class has zero probability
        mu0 ← (mu0 * (w0 - p[T]) + T * p[T]) / w0  // updated mean for class 0
        w1 ← 1 - w0
        mu1 ← (μ_T - w0 * mu0) / w1  // mean for class 1
        var ← w0 * w1 * (mu0 - mu1)^2  // between-class variance
        if var > max_var
            max_var ← var
            threshold ← T

    return threshold  // T* is the optimal threshold
This pseudocode assumes the image intensities start from 0, with class 0 encompassing levels [0, T] and class 1 [T+1, 255]; it skips thresholds where either class probability is zero to avoid . The incremental updates for w0 and mu0 avoid redundant summations in each iteration, making it suitable for practical computation on typical sizes.

MATLAB Code

MATLAB provides a built-in , graythresh, that implements Otsu's method to compute a global value in the range [0,1] for images, minimizing the intraclass variance as originally formulated. For educational purposes, the following custom implementation reproduces the core algorithm using vectorized operations and the from the Image Processing Toolbox, following the logic of iterating over possible values to maximize between-class variance.
matlab
function level = otsu(I)
    % OTSU Computes Otsu's threshold for grayscale image I.
    %   level = otsu(I) returns the threshold level in [0,1].
    
    if ndims(I) > 2
        error('Input image must be grayscale.');
    end
    
    % Compute histogram (assuming 8-bit grayscale)
    counts = imhist(I);
    counts = counts(:);
    total = sum(counts);
    if total == 0
        level = 0;
        return;
    end
    
    p = counts / total;  % Probability distribution
    mu = sum((0:255)' .* p);  % Total mean
    
    max_var = 0;
    threshold = 0;
    
    for t = 1:255
        w0 = sum(p(1:t));  % Weight of background
        if w0 == 0
            continue;
        end
        w1 = 1 - w0;  % Weight of foreground
        if w1 == 0
            break;
        end
        
        mu0 = sum((0:t-1)' .* p(1:t)) / w0;  % Background mean
        mu1 = (mu - w0 * mu0) / w1;  % Foreground mean
        
        var_between = w0 * w1 * (mu0 - mu1)^2;  % Between-class variance
        
        if var_between > max_var
            max_var = var_between;
            threshold = t;
        end
    end
    
    level = threshold / 255;  % Normalize to [0,1]
end
To visualize the results, the function can be integrated with plotting commands. For instance, after computing the , display the original alongside the binarized version:
matlab
I = imread('cameraman.tif');  % Standard grayscale test image
level = otsu(I);
binary = imbinarize(I, level);  % Binarize using the computed level

figure;
imshowpair(I, binary, 'montage');
title('Original Image and Otsu-Binarized Result');
This example uses the classic 'cameraman.tif' image, which is bimodal in its , making it suitable for demonstrating Otsu's thresholding. The imbinarize function applies the threshold to produce a where pixels below the level are set to 0 (black) and above to 1 (white). While efficient for most applications, this educational implementation loops over 256 levels, which is straightforward but can be optimized further for larger bit depths; in practice, MATLAB's graythresh is recommended for production use due to its optimizations and direct integration with the Image Processing Toolbox.

Python Code

Otsu's method can be implemented in Python using NumPy for efficient array operations and histogram computation, along with Matplotlib for image input and output visualization. This from-scratch approach directly follows the original algorithm by maximizing the between-class variance through a loop over possible threshold values, providing transparency into the computational steps. The implementation assumes a grayscale input image normalized to the [0, 1] range, which is standard for floating-point images loaded via Matplotlib; if the image is in integer format [0, 255], it should be scaled by dividing by 255 beforehand. To load and prepare an image, the following code reads a file and converts it to if necessary:
python
import [numpy](/page/NumPy) as [np](/page/NP)
import [matplotlib](/page/Matplotlib).pyplot as plt

# Load [image](/page/Image) (returns float in [0, 1])
[image](/page/Image) = plt.imread('image.[png](/page/PNG)')

# Convert to [grayscale](/page/Grayscale) if RGB
if len([image](/page/Image).shape) == 3:
    [image](/page/Image) = [np](/page/NP).dot([image](/page/Image)[..., :3], [0.2989, 0.5870, 0.1140])

# Ensure [0, 1] range
if [image](/page/Image).max() > 1.0:
    [image](/page/Image) = [image](/page/Image) / 255.0
The core function computes the and iterates to find the optimal T by evaluating the between-class variance for each potential split:
python
def otsu(image):
    """
    Compute Otsu's threshold for a grayscale image in [0, 1].
    
    Parameters:
    image : ndarray
        Grayscale image array.
    
    Returns:
    float
        Optimal threshold value in [0, 1].
    """
    # Compute histogram
    hist, bins = np.histogram(image.flatten(), bins=256, range=(0, 1))
    hist = hist.astype(float)
    
    total_pixels = hist.sum()
    if total_pixels == 0:
        return 0.0
    
    # Normalize histogram to probabilities
    p = hist / total_pixels
    
    # Total mean intensity
    total_mean = np.sum(bins[:-1] * p)
    
    # Initialize for variance maximization
    max_variance = 0.0
    threshold = 0.0
    weight0 = 0.0
    sum0 = 0.0
    
    for i in range(1, 257):
        # Update background class (pixels < bins[i])
        weight0 += p[i-1]
        sum0 += bins[i-1] * p[i-1]
        if weight0 == 0:
            continue
        mu0 = sum0 / weight0
        
        # Foreground class (pixels >= bins[i])
        weight1 = 1.0 - weight0
        if weight1 == 0:
            break
        mu1 = (total_mean - weight0 * mu0) / weight1
        
        # Between-class variance
        variance = weight0 * weight1 * (mu0 - mu1) ** 2
        
        if variance > max_variance:
            max_variance = variance
            threshold = bins[i]
    
    return threshold
This function flattens the 2D into a 1D array for calculation, ensuring all pixels contribute to the , and returns the that maximizes the variance. For and application, the can be used to create a , as shown below:
python
# Compute [threshold](/page/Threshold)
T = otsu([image](/page/Image))

# Apply thresholding
binary_image = [image](/page/Image) > T

# [Visualize](/page/Visualization)
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.imshow([image](/page/Image), cmap='gray')
plt.title('Original [Image](/page/Image)')
plt.axis('off')

plt.subplot(1, 2, 2)
plt.imshow(binary_image, cmap='gray')
plt.title(f'Thresholded Image (T = {T:.3f})')
plt.axis('off')

plt.tight_layout()
plt.show()
This implementation mirrors the logic in established libraries like scikit-image's threshold_otsu function, which offers an optimized version for practical use but follows the same variance maximization principle.

Variations and Extensions

Handling Noisy Images

Noise in images, such as salt-and-pepper or , introduces spurious peaks and irregularities in the , which can lead to suboptimal selection in Otsu's method by misleading the between-class variance maximization toward incorrect separations. To address this, variations of Otsu's method incorporate preprocessing steps to enhance robustness without altering the core variance-based formulation. One common approach applies filtering to the prior to computation, particularly effective against , as the operation removes impulsive outliers while preserving edges. Alternatively, Gaussian smoothing can be applied to the for Gaussian-distributed noise, reducing random fluctuations across the intensity range. After preprocessing, the standard Otsu algorithm is executed on the filtered image's to determine the . For direct modification, Gaussian can smooth the raw to suppress minor peaks caused by noise, followed by and application of the core Otsu procedure on the smoothed . Post-thresholding, morphological operations like opening or closing may be applied to the to eliminate residual noise artifacts, such as isolated pixels or small holes. The algorithm for the histogram-smoothing variation proceeds as follows:
  1. Compute the raw h from the .
  2. Apply Gaussian to obtain the smoothed : h_{sm} = h * G(\sigma), where G(\sigma) is a Gaussian kernel with standard deviation \sigma (typically tuned empirically to 2-5 bins to balance suppression and preservation of bimodal ).
  3. Normalize h_{sm} to form the p_{sm}.
  4. Execute the core Otsu on p_{sm} to find the optimal T.
  5. Binarize the original using T, optionally followed by morphological post-processing (e.g., followed by with a structuring element of size 3x3). This adaptation maintains computational efficiency close to the original method while mitigating noise-induced errors.
These techniques significantly improve performance on noisy images; for instance, median and average filtering in a robust 2D extension of Otsu achieves higher segmentation accuracy than traditional 1D or 2D Otsu on salt-and-pepper corrupted images, with misclassification errors reduced by up to 20-30% in synthetic tests compared to unfiltered baselines. Gaussian image preprocessing similarly enhances threshold stability for additive Gaussian noise, preserving essential bimodal characteristics in the histogram. The choice of \sigma is empirical, often selected via visual inspection or cross-validation on sample noisy data to avoid over-smoothing that could merge true classes. In , histogram smoothing can be implemented as:
matlab
hist_raw = imhist(gray_image);  
gaussian_kernel = fspecial('gaussian', [1 5], 2);  
hist_sm = conv(hist_raw, [gaussian_kernel](/page/kernel), 'same');  
hist_sm = hist_sm / sum(hist_sm);  % Normalize to probability  
level = graythresh(hist_sm');  % Otsu on smoothed hist  
binary_img = imbinarize(gray_image, level);  
This snippet demonstrates the and subsequent Otsu application, adaptable for various sizes based on levels.

Addressing Unbalanced Binnings

In cases where one class significantly dominates the , such as when small foreground objects occupy only a minor portion of the image, the standard Otsu's method exhibits a toward thresholds that split the larger class, often at the expense of accurately isolating the smaller class. This occurs because the between-class variance is proportional to the product of the class probabilities w_0 w_1, which reaches its maximum when the classes are roughly equal in size, leading to suboptimal segmentation for imbalanced distributions common in applications like document binarization or with sparse features. To mitigate this bias, a of Otsu's method for unbalanced incorporates class weights and within-class variances into the . The modified is defined as Q(k) = \sum_{i=1}^{2} \omega_i(k) \ln(\omega_i(k)) - \sigma_w(k), where \omega_i(k) are the weights of the two at k, and \sigma_w(k) = \sum_{i=1}^{2} \omega_i(k) \sigma_i^2(k) is the total within-class variance (assuming equal class variances but adjusted for unequal weights). This approach retains the assumptions of the original method but optimizes for better separation in imbalanced scenarios by maximizing Q(k). The algorithm proceeds identically to the core Otsu procedure—computing cumulative probabilities and means from the and iterating over possible thresholds k—but evaluates and selects the k that maximizes Q(k) instead of the standard between-class variance. This parameter-free method is calibrated inherently through the data. For instance, on a of 150 imbalanced images where the background often comprises over 90% of pixels, this generalized method achieves a Pseudo F-Measure of 87.57%, compared to 84.3% for the standard Otsu, demonstrating improved foreground detection for minority classes.

Multi-class Thresholding

While Otsu's binary thresholding excels at separating images into foreground and background classes, it falls short for multi-object images where multiple distinct intensity regions exist, necessitating k ≥ 2 thresholds to achieve accurate segmentation. One straightforward extension to multi-class thresholding is the iterative approach, which recursively applies the Otsu to sub-histograms until the desired number of thresholds is obtained. Introduced by Reddi et al., this method first computes the optimal threshold T_1 on the full spanning gray levels [0, L-1], then applies Otsu to the sub-histogram [T_1 + 1, L-1] to find T_2, and continues this process for subsequent thresholds up to k, effectively partitioning the image into k+1 classes. This recursive strategy approximates the global optimum while maintaining the core variance maximization criterion, though it may not always yield the exact solution due to its sequential nature. For a more precise but computationally intensive alternative, the exhaustive search method evaluates all possible combinations of ordered thresholds to directly maximize the total between-class variance across k+1 classes. In this formulation, for k=2 (triclass thresholding), every pair (T_1 < T_2) is tested, where the classes are defined as [0, T_1], [T_1 + 1, T_2], and [T_2 + 1, L-1], and the objective is to maximize the summed between-class variances: \sigma_b^{\text{total}}(T_1, T_2) = \sigma_b(T_1) + \sigma_b(T_2 \mid T_1) Here, \sigma_b(T_1) is the binary between-class variance for the initial split, and \sigma_b(T_2 \mid T_1) is the variance computed within the higher-intensity sub-histogram. The complexity of this brute-force enumeration grows exponentially as O(L^k), rendering it impractical for large k or high L (e.g., 256 gray levels). To mitigate this computational burden in modern implementations, dynamic programming techniques optimize the search by precomputing cumulative statistics and recursively building optimal sub-solutions, achieving a reduced of O(k L^2). Liao et al. pioneered this efficient dynamic programming framework for multilevel Otsu thresholding, enabling exact solutions for moderate k values without exhaustive enumeration. These advancements have made multi-class extensions viable for practical image processing applications involving complex scenes.

Limitations and Comparisons

Key Limitations

Otsu's method relies on the assumption of a to effectively separate foreground and background classes by maximizing between-class variance. However, it performs poorly on images with unimodal or flat , such as those resulting from uniform illumination, where the lack of distinct peaks leads to an arbitrary or unstable threshold selection. In such cases, the method may fail to identify meaningful separations, resulting in suboptimal segmentation outcomes. The algorithm is particularly sensitive to , including Salt-and-Pepper and Gaussian types, as intensity spikes distort the peaks and alter the variance calculations, leading to inaccurate thresholds. While variations like two-dimensional extensions can mitigate this by incorporating neighborhood information, they introduce additional parameters that increase complexity without fully resolving the issue in heavily corrupted images. In scenarios with imbalanced sizes or variances, Otsu's tends to toward the of the larger or higher-variance , skewing the segmentation and potentially misclassifying significant portions of the . This limitation arises from the method's reliance on global variance maximization, which favors dominant distributions. For multi-level thresholding, the exhaustive search over all possible combinations results in , making it impractical beyond three levels without optimizations, as the required iterations grow rapidly with the number of . As a histogram-based, non-parametric approach, Otsu's method disregards spatial correlations and contextual relationships among pixels, treating the image as an independent collection of intensities. This oversight leads to failures in segmenting objects with irregular boundaries or textured regions, where local variations are not accounted for. Empirical evaluations on non-bimodal or noisy images demonstrate that Otsu's method yields misclassification error rates of approximately 15-18%, significantly higher—often by orders of magnitude—than supervised or adaptive alternatives, highlighting its reduced reliability in real-world scenarios deviating from ideal bimodal assumptions. Benchmark evaluations, such as those on images, show Otsu's method achieving misclassification errors around 20%, corresponding to approximately 80% accuracy in class separation for bimodal cases, with higher errors in complex scenarios.

Comparison with Other Thresholding Methods

Otsu's method provides a computationally efficient global thresholding approach compared to iterative techniques like the Ridler-Calvard algorithm, which refines the threshold through successive approximations based on class means. The Ridler-Calvard method exhibits a of O(L × I), where L is the number of gray levels and I is the number of iterations (typically 5–10), whereas Otsu's exhaustive search over possible thresholds achieves O(L) complexity after histogram computation. However, the iterative nature of Ridler-Calvard allows it to converge to a global optimum in histograms with plateaus, where Otsu's variance maximization may select a suboptimal point within a flat region, potentially leading to less precise separation in such cases. In comparison to entropy-based methods such as Kapur's, Otsu emphasizes statistical separability by maximizing between-class variance, while Kapur optimizes the of entropies to enhance information preservation. This distinction makes Kapur more effective for d images, where intricate patterns require thresholds that retain detailed boundary information, outperforming Otsu in scenarios with high intra-class variability. Otsu's variance criterion, by contrast, excels in scenarios with clear statistical separation but may underperform when dominates the shape. Unlike local adaptive methods such as Niblack's, which derive pixel-specific thresholds using local mean and standard deviation within sliding windows to accommodate uneven illumination, Otsu employs a single global that overlooks regional variations. Niblack's approach handles non-uniform effectively, such as in shadowed or gradient-affected images, but at the cost of increased due to local processing (O(N × W²), where N is the number of pixels and W is the window size). In benchmarks, Otsu demonstrates superior speed for uniform conditions but lower accuracy under inconsistencies compared to adaptive techniques. Relative to machine learning-based methods like applied to pixel intensities, Otsu operates without parameters or training data, relying solely on the histogram for rapid execution, whereas k-means requires specifying the number of clusters (typically 2 for binarization) and initial centroids, enabling higher accuracy through iterative optimization but demanding more computational resources and sensitivity to starting conditions. K-means achieves better segmentation in multi-modal or noisy distributions by adapting to data clusters, though Otsu's parameter-free design makes it preferable for quick, applications.

Applications

In Image Segmentation

Otsu's method serves as a foundational thresholding technique in image segmentation pipelines, acting as the initial step to partition an image into distinct regions by separating foreground objects from the background based on intensity distributions. By automatically determining the optimal T^* that maximizes between-class variance, it enables efficient binarization of images, converting them into binary masks where exceeding T^* are assigned to the object class and those below to the background. This process is particularly effective for images exhibiting bimodal histograms, where clear intensity peaks correspond to distinct regions, facilitating the isolation of objects for subsequent analysis. Following binarization, is applied to identify and enumerate individual segmented objects, allowing for object-specific processing such as size filtering or feature extraction. The typical workflow integrates Otsu's thresholding with post-processing steps to enhance segmentation quality. After binarization with T^*, morphological operations are employed to refine the resulting mask: closing (dilation followed by ) fills small gaps within object contours, while opening ( followed by ) eliminates isolated noise pixels, yielding smoother and more accurate boundaries. This refined then supports higher-level tasks like region growing or contour tracing. In practice, these steps form a robust for automating segmentation without manual intervention, reducing computational overhead compared to iterative manual thresholding. In , Otsu's method is widely applied to segment cellular structures in images, such as isolating nuclei or from surrounding for diagnostic quantification and . For instance, it effectively delineates boundaries in histological slides, enabling automated counting and morphological assessment critical for workflows. Similarly, in document scanning applications, the method binarizes scanned pages to separate text foreground from the background, enhancing preprocessing for (OCR) systems by improving text legibility and reducing errors in character extraction. These examples highlight its utility in domains requiring precise region isolation from complex backgrounds. To address limitations in boundary precision, Otsu's method is often enhanced by integration with edge detection algorithms, such as the Canny operator, for boundary verification. In this hybrid approach, Canny edges are computed on the original image and overlaid with the Otsu-derived mask to confirm and adjust contours, mitigating issues like over-segmentation in low-contrast areas. This combination leverages Otsu's global optimality for initial partitioning while incorporating local edge cues for refinement, resulting in more reliable object outlines. In bimodal scenarios, such pipelines have demonstrated substantial improvements in segmentation metrics like Intersection over Union (IoU) over simplistic fixed-threshold methods, such as mid-gray binarization, by better aligning predicted regions with ground truth.

Real-World Use Cases

Otsu's method, originally proposed by Nobuyuki Otsu in 1979 for automatic threshold selection in gray-level histograms to support tasks, has found extensive practical deployment across diverse fields due to its computational efficiency and robustness in bimodal image distributions. In modern applications, it remains a staple in open-source image processing software, implemented as the default auto-thresholding approach in tools like and integrated into libraries such as for streamlined workflows. In , Otsu's thresholding is widely utilized within the library for real-time in , where it preprocesses images to binarize features like edges or patterns, facilitating tasks such as QR code scanning by separating the code from complex backgrounds. This integration enables efficient, hardware-accelerated processing on embedded systems, enhancing autonomy in robotic navigation and inventory management. In biomedical imaging, the method supports automatic segmentation of cell nuclei in histopathology slides, improving diagnostic accuracy by isolating stained regions from tissue backgrounds in hematoxylin-eosin images. It is incorporated into plugins for , an open-source platform popular in analysis, allowing researchers to apply multilevel thresholding for quantitative studies without manual intervention. Industrial applications leverage Otsu's method for quality control in manufacturing, particularly in defect detection on assembly lines, where it thresholds images to highlight surface anomalies like scratches or inconsistencies on products such as pharmaceutical tablets or wafers. By automating edge-based segmentation, it reduces times and error rates, enabling high-throughput monitoring in automated production environments. In , Otsu's thresholding aids classification from , effectively separating features like water bodies from vegetation or urban areas by optimizing thresholds on multispectral histograms. This approach has been combined with classifiers like to achieve over 85% accuracy in delineating water, snow, ice, and vegetation classes, supporting and . Post-2020 developments have seen Otsu's method integrated into pipelines as a preprocessing step for convolutional neural networks (CNNs), particularly in self-driving vehicle vision systems for lane marking detection under varying lighting conditions. For instance, it enhances in complex road scenes, improving the reliability of lane segmentation before feeding data into models for path planning.

References

  1. [1]
    A Threshold Selection Method from Gray-Level Histograms
    A Threshold Selection Method from Gray-Level Histograms. Published in: IEEE ... ISSN Information: DOI: 10.1109/TSMC.1979.4310076. Publisher: IEEE. Authors ...
  2. [2]
    [PDF] Reviewing Otsu's Method For Image Thresholding
    Otsu's method improves image thresholding by finding optimal thresholds, minimizing intra-class variance, and is fast, operating on the gray level histogram.
  3. [3]
  4. [4]
    [PDF] Digital Image Processing: Introduction
    1970s: Digital image processing begins to be used in medical applications ... – History of digital image processing. – State of the art examples of digital ...
  5. [5]
    A robust 2D Otsu's thresholding method in image segmentation
    In this paper we focus on Ostu's method and aim to improve its robustness. Otsu's method was proposed by Nobuyuki Otsu in 1979 and is widely used in document ...
  6. [6]
    A Threshold Selection Method from Gray-Level Histograms
    This paper presents a simple but effective example showing that the histogram-based thresholding methods do not perform well, and proposes a new gray level ...
  7. [7]
    Image Thresholding - OpenCV Documentation
    Similarly, Otsu's method determines an optimal global threshold value from the image histogram. In order to do so, the cv.threshold() function is used, where cv ...
  8. [8]
    An Advanced Otsu Method Integrated with Edge Detection and ...
    Jul 21, 2021 · This paper developed an improved Otsu method integrated with edge detection and a decision tree classifier for cracking identification in asphalt pavements.2. Methodology · 2.2. Edge Detection · 3. Discussion Of Results
  9. [9]
    [PDF] Lecture 4: Thresholding
    Jan 12, 2000 · Thresholding separates light and dark regions, creating binary images by setting pixels below a threshold to zero and above to one.Missing: challenges | Show results with:challenges
  10. [10]
    Image Processing with Python: Thresholding - Data Carpentry
    Feb 9, 2025 · Thresholding is a type of image segmentation, where we change the pixels of an image to make the image easier to analyze.
  11. [11]
    [PDF] A Tlreshold Selection Method from Gray-Level Histograms
    The method is a nonparametric, unsupervised method using a discriminant criterion to maximize separability, using zeroth and first-order cumulative moments.
  12. [12]
    Image Histogram - an overview | ScienceDirect Topics
    An image histogram is a gray-scale value distribution showing the frequency of occurrence of each gray-level value. For an image size of 1024 × 1024 × 8 bits, ...
  13. [13]
  14. [14]
  15. [15]
    graythresh - Global image threshold using Otsu's method - MATLAB
    Otsu's method chooses a threshold that minimizes the intraclass variance of the thresholded black and white pixels. The global threshold T can be used with ...
  16. [16]
  17. [17]
    [PDF] Improving Otsu's Thresholding Method of Global Binarization Using ...
    Nov 13, 2021 · Gaussian filters are used to smooth images and remove any noise [6] ... noise removal, which ultimately caused reproduced images to be of lower ...
  18. [18]
  19. [19]
    A Fast Algorithm for Multilevel Thresholding. - ResearchGate
    Aug 6, 2025 · In this paper, a faster version of Otsu's method is proposed for improving the efficiency of computation for the optimal thresholds of an image.
  20. [20]
    A novel histogram transformation to improve the performance of ...
    ▻ The Otsu thresholding method has a low performance on unimodal histograms. ... limitations and automatically determining a suitable optimal threshold for ...
  21. [21]
    Thresholding - Introduction to Bioimage Analysis
    However, if we apply a Gaussian filter to smooth the image, a lot of the the random noise is reduced (see Filters). This results in a histogram dramatically ...
  22. [22]
    Improving the Otsu method for MRA image vessel extraction via ...
    The Otsu method has been used for extracting vessels in medical images. However, blood vessels in magnetic resonance angiography (MRA) image are considered as a ...
  23. [23]
    Separate degree based Otsu and signed similarity driven level set ...
    Firstly, we prove that the widely used Otsu threshold has bias towards one class with larger variance, and the bias degree varies with the size difference of ...Missing: imbalance | Show results with:imbalance
  24. [24]
    [PDF] A generalization of Otsu method for linear separation of two ...
    Pseudo F-Measure, the metric employed in DIBCO, is analyzed. We demonstrate that the unbalanced Otsu method modification [20] is better than the classical Otsu ...
  25. [25]
    Optimal multi-level thresholding using a two-stage Otsu optimization ...
    Feb 1, 2009 · The TSMO method outperforms Otsu's method by greatly reducing the iterations required for computing the between-class variance in an image.
  26. [26]
    [PDF] Deng-Yuan Huang , Ta-Wei Lin and Wu-Chih Hu - ijicic
    In this paper, a modified version of the TSMO method that can provide the same set of thresholds as those obtained using the original Otsu method but without ...Missing: steps | Show results with:steps
  27. [27]
    A context sensitive energy thresholding based 3D Otsu function for ...
    In this paper, a novel context-based 3D Otsu algorithm using human learning optimization (HLO) is proposed for multilevel color image segmentation.
  28. [28]
    Segmentation of Fluorescence Microscopy Images for Quantitative ...
    The misclassification error for Otsu's method is roughly three-orders-of-magnitude larger than the SCT algorithm. This error is driven by the high false ...
  29. [29]
    (PDF) Survey over image thresholding techniques and quantitative ...
    Aug 7, 2025 · Survey over image thresholding techniques and quantitative performance evaluation. January 2004; Journal of Electronic Imaging 13(1):146-168.
  30. [30]
    Ridler and Calvard's, Kittler and Illingworth's and Otsu's methods for ...
    Aug 5, 2025 · There are close relationships between three popular approaches to image thresholding, namely Ridler and Calvard's iterative-selection (IS) method, Kittler and ...
  31. [31]
    A Review of Document Binarization: Main Techniques, New ... - MDPI
    Trier [33] believes that Niblack performs better than other local binarization methods in gray images with low contrast, noise, and uneven background intensity.
  32. [32]
    A comparison of seven thresholding techniques with the k-means ...
    The objective of this study was to assess the performance of manual threshold selection and six automated thresholding algorithms (isodata, Otsu, minimum error, ...
  33. [33]
    A Comparative Study of Otsu Thresholding and K-means Algorithm ...
    Aug 9, 2025 · Otsu method is one of the most successful methods for image thresholding because of its simple calculation. Otsu method can select threshold ...
  34. [34]
    Comparison between Otsu's Image Thresholding Technique and ...
    Abstract - Medical image segmentation is related to the segmentation of known anatomic structures from medical images. Structures consists.
  35. [35]
    Otsu's Thresholding Technique - LearnOpenCV
    Aug 5, 2020 · Otsu's Thresholding with OpenCV. In this post, we will examine Otsu's method for automatic image thresholding. What is Image Thresholding?Missing: original | Show results with:original
  36. [36]
    Image segmentation using Morphological operations in Python
    Aug 5, 2025 · Step 1: Import the required libraries · Step 2: Upload and Decode the Image · Step 3: Convert to Greyscale and Blur · Step 4: Apply OTSU's ...
  37. [37]
    An image-processing algorithm for morphological characterisation of ...
    Thus, the projected area of the agglomerate is enhanced which simplifies the binarization process performed by the Otsu's method. Connected components are then ...Missing: workflow | Show results with:workflow
  38. [38]
    An improved medical image segmentation algorithm using OTSU ...
    This paper describes a way of medical image segmentation using optimized Otsu method based on improved thresholding algorithm.
  39. [39]
    A recursive Otsu thresholding method for scanned document ...
    One combines a recursive extension of Otsu thresholding and selective bilateral filtering to allow automatic binarization and segmentation of handwritten text ...
  40. [40]
    Detection of microcracks in silicon solar cells using Otsu-Canny ...
    The Otsu-Canny edge detection technique is more accurate than other conventional edge detection algorithms for detecting microcracks, with a 92.83 % detection ...
  41. [41]
    Understanding Otsu's Method for Image Segmentation - Baeldung
    Mar 26, 2025 · Otsu's method is a popular technique employed for image thresholding. It separates an image into two classes, foreground, and background, based ...
  42. [42]
    Ridler and Calvard's, Kittler and Illingworth's and Otsu's methods for ...
    Otsu's method is implemented as the default approach to image thresholding in some commercial and free software such as MATLAB (The MathWorks, Inc.) and GIMP ( ...
  43. [43]
    Segmentation of Nuclei from Breast Histopathology Images Using ...
    Aug 6, 2025 · In this paper, we propose the use of particle swarm optimization (PSO)-based Otsu's multilevel thresholding technique to automatically segment ...<|separator|>
  44. [44]
    Otsu's method and advices - Image.sc Forum
    Sep 23, 2024 · Seeing the Signal-to-noise ratio of your images, I believe that different (Default or Huang [for example]) thresholding methods will yield ...Missing: sensitivity | Show results with:sensitivity
  45. [45]
    Automatic image thresholding using Otsu's method and entropy ...
    Aug 6, 2025 · The proposed method enables the detection of extremely small defect regions compared to the product surface area.
  46. [46]
    Detection of waterbodies in satellite image using Otsu's thresholding ...
    Aug 30, 2024 · This work aims to develop a deep-learning segmentation (DS) approach to extract and examine the waterbodies section from the chosen satellite ...
  47. [47]
    Integrating Otsu Thresholding and Random Forest for Land Use ...
    This study combined the Otsu threshold method and Random Forest algorithm to generate a 10 m-resolution land cover classification map for Wensu County based on ...
  48. [48]
    Lane Line Detection and Object Scene Segmentation Using Otsu ...
    An Otsu-threshold- and Canny-edge-detection-based fast Hough transform (FHT) approach to lane detection was proposed to improve the accuracy of lane detection ...
  49. [49]
    Lane Line Detection and Object Scene Segmentation Using Otsu ...
    Feb 17, 2023 · An Otsu-threshold- and Canny-edge-detection-based fast Hough transform (FHT) approach to lane detection was proposed to improve the accuracy of lane detection ...