Adaptive Threshold

Adaptive Threshold

1. Otsu's Binarization:

  1. Using a discriminant analysis to partition the image into 2 classes C0 = {0, 1, 2, ..., t} and C1 = {t+1, t+2, ..., L-1} at which is the total number of the gray levels in image;

  2. (1). Let n be the total number of pixels in the image,

    (2). the probabilities of the two classes equal to (w_0 = sumlimits_{i=1}^{t}{p_i}), (w_1 = sumlimits_{i=t+1}{L-1}{p_i}),

    (3). and so are the means: (mu_0(t) = sum_{i=0}^{t}{frac{i*p_i}{w_0}} = sum_{i=0}^{t}{frac{i*p_i}{{sum_{i=0}^{t}{p_i}}}}), (mu_1(t) = sum_{i=t+1}^{L-1}{frac{i*p_i}{w_1}} = sum_{i=t+1}^{L-1}{frac{i*p_i}{w_1}} = sum_{i=t+1}^{L-1}{frac{i*p_i}{{sum_{i=t+1}^{L-1}{p_i}}}}),

    (4). (sigma^{2}_{B}) and (sigma^{2}_{T}) -- the variance in between classes and total variance,

    (5). (mu = sum_{i=0}^{L-1}{i*p_i});

  3. An optimal threshold t* can be computed by maxmizing the (sigma_{B}^{2}) -- (t^2 = Arg{maxlimits_{0<=i<=L-1}{(frac{sigma_{B}^{2}}{sigma_T^2})}}), where (sigma_B^2 = w_{0} * (mu_{0} - mu_{T})^{2} + w_{1} * (mu_1 - mu_T)^{2}) and (sigma_{T}^{2} = sum_{i=1}^{L-1}{(i-mu_{T})^{2}});

  4. Simplier formula: (t^{*} = Arg{maxlimits_{0<=i<=L}{(w_{0}*[mu_0-mu_T]^{2}+w_{1}*[mu_{1} - mu_{T}]^{2}})})

2. Bernsen's Method:

  1. [Used when]: different parts of an image show large varivation between background and foreground, especially as a result of darkness or shadow.

  2. Steps:

    (1). Let f(x, y) denotes the gray value in point(x, y);

    (2). For a (2w+1)x(2w+1) mask centered at point(x, y), and the threshold T(x, y) characteristic to image is: T(x, y) = 0.5 x ((maxlimits_{-w<=m<=w, -w<=n<=w}f(x+m, y+m) + minlimits_{-w<=m<=w, -w<=n<=w}f(x+m, y+m)))
    P.S. It's necessary that mask size should be adapted to the size of the existing objects.

3. Niblack's Method:

  1. [Definition]: A local thresholding method that adapts the threshold's valuebased on local mean and local standard deviation, with a specific rectangular window around each pixel location.

  2. Formula:

    Notation: m -- local mean value;
    k -- represents size of window, recommended value: -0.2, adjust it -- trying to improve denoising efficacy and preservation of local details;
    N -- number of pixels;
    (p_i^2) -- value of the i-th pixel;
    std -- standard-deviation.

    (displaystyle T(x, y) = m(x, y) + k*sqrt{frac{sum_i{p_i^2}}{NP} - m(x, y)^2} = m(x, y) + k*sqrt{std(x, y)})

原文地址:https://www.cnblogs.com/ZhengPeng7/p/7690556.html