# how can we tell that OTSU binarization is feasible or not.

OTSU is a very popular image binarization method, and Matlab provides a function to implement this method, see graythresh for details. In this function, it has two outputs, one is the threshold calculated with OTSU algorithm, the other is called effectiveness metric EM, and it claims:

    The effectiveness metric is a value in the range [0 1] that indicates the
effectiveness of the thresholding of the input image. The lower bound is
attainable only by images having a single gray level, and the upper bound is
attainable only by two-valued images.


I think it would be nice if we can use effectiveness metric EM to tell whether binarization is fine or not. If EM value is slow, then we will use different binarization method. It would be very useful in the context of document image binarization. Then, a natural question is how can we set this threshold reasonablly. Any ideas on how EM is calculated?

Assuming you have MATLAB, you can just look at the source code, where you will see that the EM is defined as

em = maxval/(sum(p.*((1:num_bins).^2)') - mu_t^2);

where

I = im2uint8(I(:)); # the input image
num_bins = 256;
counts = imhist(I,num_bins);
p = counts / sum(counts);
omega = cumsum(p)
mu = cumsum(p .* (1:num_bins)');
mu_t = mu(end);
sigma_b_squared = (mu_t * omega - mu).^2 ./ (omega .* (1 - omega));
maxval = max(sigma_b_squared);