请输入您要查询的百科知识:

 

词条 Otsu's method
释义

  1. Otsu's Method

     Algorithm  MATLAB or Octave implementation 

  2. Limitations

  3. Improvements

     Algorithm  Matlab implementation 

  4. References

  5. External links

In computer vision and image processing, Otsu's method, named after {{Nihongo|Nobuyuki Otsu|大津展之|Ōtsu Nobuyuki}}, is used to automatically perform clustering-based image thresholding,[1] or, the reduction of a graylevel image to a binary image. The algorithm assumes that

the image contains two classes of pixels following bi-modal histogram (foreground pixels and background pixels), it then calculates the optimum threshold separating the two classes so that their combined spread (intra-class variance) is minimal, or equivalently (because the sum of pairwise squared distances is constant), so that their inter-class variance is maximal.[2]

Consequently, Otsu's method is roughly a one-dimensional, discrete analog of Fisher's Discriminant Analysis. Otsu's method is also directly related to the Jenks optimization method.

The extension of the original method to multi-level thresholding is referred to as the multi Otsu method.[3]

Otsu's Method

In Otsu's method we exhaustively search for the threshold that minimizes the

intra-class variance (the variance within the class), defined as a weighted sum of variances of the two classes:

Weights and are the probabilities of the two classes separated

by a threshold ,and and are variances of these two classes.

The class probability is computed from the bins of the histogram:

Otsu shows that minimizing the intra-class variance is the same as maximizing inter-class variance:[2]

which is expressed in terms of class probabilities and

class means .

while the class mean is:

The following relations can be easily verified:

The class probabilities and class means can be computed iteratively. This idea

yields an effective algorithm.

Algorithm

  1. Compute histogram and probabilities of each intensity level
  2. Set up initial and
  3. Step through all possible thresholds maximum intensity
    1. Update and
    2. Compute
  4. Desired threshold corresponds to the maximum

MATLAB or Octave implementation

histogramCounts is a 256-element histogram of a grayscale image different gray-levels (typical for 8-bit images).

level is the threshold for the image (double).

function level = otsu(histogramCounts)

total = sum(histogramCounts); % total is the number of pixels in the given image.

%% OTSU automatic thresholding method

sumB = 0;

wB = 0;

maximum = 0.0;

sum1 = dot( (0:255), histogramCounts);

for ii=1:256

    wB = wB + histogramCounts(ii-1);    wF = total - wB;    if (wB == 0 || wF == 0)        continue;    end    sumB = sumB +  (ii-1) * histogramCounts(ii-1);    mF = (sum1 - sumB) / wF;    between = wB * wF * ((sumB / wB) - mF) * ((sumB / wB) - mF);    if ( between >= maximum )        level = ii;        maximum = between;    end

end

end

Matlab has built-in functions graythresh() and multithresh() in the Image Processing Toolbox which are implemented with Otsu's method and Multi Otsu's method, respectively.

Limitations

Otsu's method exhibits the relatively good performance if the histogram can be assumed to have bimodal distribution and assumed to possess a deep and sharp valley between two peaks. But if the object area is small compared with the background area, the histogram no longer exhibits bimodality.[4] And if the variances of the object and the background intensities are large compared to the mean difference, or the image is severely corrupted by additive noise, the sharp valley of the gray level histogram is degraded. Then the possibly incorrect threshold determined by Otsu's method results in the segmentation error. (Here we define the object size to be the ratio of the object area to the entire image area and the mean difference to be the difference of the average intensities of the object and the background)

From the experimental results, the performance of global thresholding techniques including Otsu's method is shown to be limited by the small object size, the small mean difference, the large variances of the object and the background intensities, the large amount of noise added, and so on.[5]

Improvements

There are many improvements focusing on different limitations for Otsu's method.[6] One famous and effective way is known as two-dimensional Otsu's method. In this approach, the gray-level value of each pixel as well as the average value of its immediate neighborhood is studied so that the binarization results are greatly improved, especially for those images corrupted by noise.[7]

At each pixel, the average gray-level value of the neighborhood is calculated. Let the gray level of a given picture be divided into values and the average gray level is also divided into the same values. Then a pair is formed: the pixel gray level and the average of the neighborhood. Each pair belongs to a 2-dimensional bin. The total number of bins is obviously . The total number of occurrence(frequency), , of a pair divided by the total number of pixels in the image , defines the joint probability mass function in 2-dimensional histogram:

And the 2-dimensional Otsu's method will be developed based on

the 2-dimensional histogram as follows.

The probabilities of two classes can be denoted as:

The intensity means value vectors of two classes and total mean vector can be expressed as follows:

In most cases, the probability off-diagonal will be negligible so it's easy to verify:

The inter-class discrete matrix is defined as

The trace of discrete matrix can be expressed as

where

Similar to one-dimensional Otsu's method, the optimal threshold is obtained by maximizing .

Algorithm

The and is obtained iteratively which is similar with one-dimensional Otsu's method. The values of and are changed till we obtain the maximum of , that is

max,s,t = 0;

for ss: 0 to L-1 do

    for tt: 0 to L-1 do        evaluate tr(S_b);        if tr(S_b) > max            max = tr(S,b);            s = ss;            t = tt;        end if    end for

end for

return s,t;

Notice that for evaluating , we can use a fast recursive dynamic programming algorithm to improve time performance.[8] However, even with the dynamic programming approach, 2d Otsu's method still has large time complexity. Therefore, many researches have been done to reduce the computation cost.[9]

If summed area tables are used to build the 3 tables, sum over P_i_j, sum over i * P_i_j,

and sum over j * P_i_j, then the runtime complexity is the

maximum of (O(N_pixels), O(N_bins*N_bins)). Note that if only coarse resolution is needed in terms

of threshold, N_bins can be reduced.

{{see also|Summed_area_table}}

Matlab implementation

function inputs and output:

hists is a 2D-histogram of grayscale value and neighborhood average grayscale value pair.

total is the number of pairs in the given image.it is determined by the number of the bins of 2D-histogram at each direction.

threshold is the threshold obtained.

function threshold = otsu_2D(hists, total)

maximum = 0.0;

threshold = 0;

helperVec = 0:255;

mu_t0 = sum(sum(repmat(helperVec',1,256).*hists));

mu_t1 = sum(sum(repmat(helperVec,256,1).*hists));

p_0 = zeros(256);

mu_i = p_0;

mu_j = p_0;

for ii = 1:256

    for jj = 1:256        if jj == 1            if ii == 1                p_0(1,1) = hists(1,1);            else                p_0(ii,1) = p_0(ii-1,1) + hists(ii,1);                mu_i(ii,1) = mu_i(ii-1,1)+(ii-1)*hists(ii,1);                mu_j(ii,1) = mu_j(ii-1,1);            end        else            p_0(ii,jj) = p_0(ii,jj-1)+p_0(ii-1,jj)-p_0(ii-1,jj-1)+hists(ii,jj);            mu_i(ii,jj) = mu_i(ii,jj-1)+mu_i(ii-1,jj)-mu_i(ii-1,jj-1)+(ii-1)*hists(ii,jj);            mu_j(ii,jj) = mu_j(ii,jj-1)+mu_j(ii-1,jj)-mu_j(ii-1,jj-1)+(jj-1)*hists(ii,jj);        end
        if (p_0(ii,jj) == 0)            continue;        end        if (p_0(ii,jj) == total)            break;        end        tr = ((mu_i(ii,jj)-p_0(ii,jj)*mu_t0)^2 + (mu_j(ii,jj)-p_0(ii,jj)*mu_t1)^2)/(p_0(ii,jj)*(1-p_0(ii,jj)));
        if ( tr >= maximum )            threshold = ii;            maximum = tr;        end    end

end

end

References

1. ^{{cite journal|author1=M. Sezgin |author2=B. Sankur |lastauthoramp=yes | year = 2004| title = Survey over image thresholding techniques and quantitative performance evaluation| volume = 13| issue = 1| pages = 146–165| journal = Journal of Electronic Imaging| doi = 10.1117/1.1631315}}
2. ^{{cite journal| author = Nobuyuki Otsu| year = 1979| title = A threshold selection method from gray-level histograms| volume = 9| issue = 1| pages = 62–66| journal = IEEE Trans. Sys., Man., Cyber.| doi = 10.1109/TSMC.1979.4310076}}
3. ^{{cite journal| author = Ping-Sung Liao and Tse-Sheng Chen and Pau-Choo Chung| title = A Fast Algorithm for Multilevel Thresholding| journal = J. Inf. Sci. Eng.| volume = 17| year = 2001| pages = 713–727| issue = 5}}
4. ^{{cite journal|author1=Kittler, Josef |author2=Illingworth, John |lastauthoramp=yes | year = 1985| title = On threshold selection using clustering criteria| volume = SMC-15| issue = 5| pages = 652–655| journal = Systems, Man and Cybernetics, IEEE Transactions on | doi=10.1109/tsmc.1985.6313443}}
5. ^{{cite journal| author = Lee, Sang Uk and Chung, Seok Yoon and Park, Rae Hong| year = 1990| title = A comparative performance study of several global thresholding techniques for segmentation| volume = 52| issue = 2| pages = 171–190| journal = Computer Vision, Graphics, and Image Processing| doi=10.1016/0734-189x(90)90053-x}}
6. ^{{cite journal|author1=Vala, HJ |author2=Baxi, Astha |lastauthoramp=yes | year = 2013| title = A review on Otsu image segmentation algorithm| volume = 2| issue = 2| pages = 387| journal = International Journal of Advanced Research in Computer Engineering \\& Technology (IJARCET)}}
7. ^{{cite journal| author = Jianzhuang, Liu and Wenqing, Li and Yupeng, Tian| year = 1991| title = Automatic thresholding of gray-level pictures using two-dimension Otsu method| pages = 325–327| journal = Circuits and Systems, 1991. Conference Proceedings, China., 1991 International Conference on}}
8. ^{{cite journal|author1=Zhang, Jun |author2=Hu, Jinglu |lastauthoramp=yes | year = 2008| title = Image segmentation based on 2D Otsu method with histogram analysis| volume = 6| pages = 105–108| journal = Computer Science and Software Engineering, 2008 International Conference on}}
9. ^{{cite journal| author = Zhu, Ningbo and Wang, Gang and Yang, Gaobo and Dai, Weiming| year = 2009| title = A fast 2d otsu thresholding algorithm based on improved histogram| pages = 1–5| journal = Pattern Recognition, 2009. CCPR 2009. Chinese Conference on}}

External links

  • [https://github.com/cbhushan/script-collection/blob/master/GIMP-plugins/otsu-threshold.scm Implementation of Otsu's thresholding method] as GIMP-plugin using Script-Fu (a Scheme-based language).
  • Lecture notes on thresholding – covers the Otsu method.
  • A plugin for ImageJ using Otsu's method to do the threshold.
  • A full explanation of Otsu's method with a working example and Java implementation.
  • Implementation of Otsu's method in ITK
  • Otsu Thresholding in C# A straightforward C# implementation with explanation.
  • Otsu's method using MATLAB

2 : Image segmentation|Statistical deviation and dispersion

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/24 3:21:45