5-auto thresholding clustering

Upload: thanlannui-tn

Post on 05-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 5-Auto Thresholding Clustering

    1/13

    Auto_thresholding_clustering: 1 Copyright 2011: Paul F. Whelan.

    Automated Thresholds Clustering

    Thresholding Revisited!

    View as a clustering problem problem is that the range of values may overlap

    Want to minimise the error in classification (e.g. misclassifying a foreground pixelas a background one)

  • 7/31/2019 5-Auto Thresholding Clustering

    2/13

    Auto_thresholding_clustering: 2 Copyright 2011: Paul F. Whelan.

    Automated Thresholds Otsu MethodN. Otsu (1979). "A threshold selection method from gray-level histograms". IEEE Trans. Sys., Man., Cyber. 9: 6266

    Otsu method: Simple idea, find the threshold that minimizes the weighted intra (within) classvariance.

    This is the same as the same as maximizing the inter (between) class variance

    Set the threshold so each cluster is as tight as possible with a view to minimizing any overlap (!)

    Cannot change the distributions so we adjust where we separate them (threshold)

    As we adjust the threshold one way we increase the spread of one and decrease the spreadof the other

    Goal: to select threshold that minimizes the combined spread

  • 7/31/2019 5-Auto Thresholding Clustering

    3/13

    Auto_thresholding_clustering: 3 Copyright 2011: Paul F. Whelan.

    Assumes the image to be threshold contains two classes of pixels (bimodal -foreground and background)

    Calculates the OPTIMAL threshold to separate these two classes so that theircombined intra (within) class variance is minimal

    Operates directly on a pre computed grey level histogram fast!

    Based solely on intensity information no spatial context.

    Assumes uniform illumination (implicitly), so the bimodal brightness behavior

    arises only from differences in the objects appearance.

  • 7/31/2019 5-Auto Thresholding Clustering

    4/13

    Auto_thresholding_clustering: 4 Copyright 2011: Paul F. Whelan.

    Weighted within class variancebetween object (O) and the background (B) is:)()()()()( 222 ttttt OOBBwithin

    Where the class probabilities are estimated as:

    1

    0

    )()(t

    i

    B ipt

    1

    )()(N

    ti

    O ipt

    )(2tB = the variance of the pixels in the background (below threshold)

    )(

    2

    tO = the variance of the pixels in the foreground (above threshold)

    [0, N-1] is the range of intensity values.

  • 7/31/2019 5-Auto Thresholding Clustering

    5/13

    Auto_thresholding_clustering: 5 Copyright 2011: Paul F. Whelan.

    Mean (Expected Value)

    N

    i

    iipxxE

    1

    Variance 2

    1

    22)()(

    ipxEN

    i

    i

    Class means are given by:

    1

    0 )(

    )()(

    t

    iB

    Bt

    iipt

    1

    )(

    )()(

    N

    tiO

    Ot

    iipt

    Individual class variances are:

    1

    0

    22

    )(

    )()]([)(

    t

    i B

    BBt

    iptit

    1

    22

    )(

    )()]([)(

    N

    ti O

    OOt

    iptit

  • 7/31/2019 5-Auto Thresholding Clustering

    6/13

    Auto_thresholding_clustering: 6 Copyright 2011: Paul F. Whelan.

    Computing the within class variance for each of our two classes for each possiblethreshold (ie run through the full range of tvalues [0,N-1]and pick the value that

    minimizes )(2

    twithin ) is computational expensive so we reformulate the problem

    The relationship between the within-class and between-class variances can beexploited to generate a recursion relation that permits a much faster calculation.

    Between class variance = total variance within class variance

    )()(222

    tt withinbetween

    22])()[(])()[( tttt OOBB

    Where2

    is the combined variance, and is the combined mean

    The between class variance is simply the weighted variance of the cluster meansthemselves around the overall mean.

  • 7/31/2019 5-Auto Thresholding Clustering

    7/13

    Auto_thresholding_clustering: 7 Copyright 2011: Paul F. Whelan.

    Substituting )()()()( tttt OOBB and simplifying we get

    22

    )]()()[()()( ttttt OBOBbetween

    Algorithm

    Compute histogram and probabilities of each intensity level

    Set up initial i(0) and i(0)

    For each potential threshold

    1. Separate the pixels into two clusters according to the threshold

    2. Find the mean of each cluster

    3. Square the difference between the means

    4. Multiply by the number of pixels in each cluster

    Desired threshold corresponds to the maximum )(2

    tbetween

    Still computationally expensive!

  • 7/31/2019 5-Auto Thresholding Clustering

    8/13

    Auto_thresholding_clustering: 8 Copyright 2011: Paul F. Whelan.

    Otsu Method Iterative approach

    The nice thing about this is that we can compute the quantities in

    )(2

    tbetween

    recursivelyas werun through the range of tvalues.

    Computations are not independent as we change from one threshold to another

    We can update B(T) and O(T) and the respective cluster means B(T) and O(T) as pixelsmove from one cluster to the other as tincreases.

    Using recurrence relations we can update the between-class variance as we successively

    test each threshold:

    Initialization: )1()1( pB 0)0( b

    Recursion: )()()1( tptt BB )()()1( tptt OO

    )1(

    )()()()1(

    t

    ttptttB

    BBB

    )1(

    )()()()1(

    t

    ttptttO

    OOO

  • 7/31/2019 5-Auto Thresholding Clustering

    9/13

  • 7/31/2019 5-Auto Thresholding Clustering

    10/13

    Auto_thresholding_clustering: 10 Copyright 2011: Paul F. Whelan.

    Dr. Andrew Greensted - labbookspages - worked example (threshold = 3)

  • 7/31/2019 5-Auto Thresholding Clustering

    11/13

    Auto_thresholding_clustering: 11 Copyright 2011: Paul F. Whelan.

  • 7/31/2019 5-Auto Thresholding Clustering

    12/13

    Auto_thresholding_clustering: 12 Copyright 2011: Paul F. Whelan.

    Works well for images with a bimodal histogram

  • 7/31/2019 5-Auto Thresholding Clustering

    13/13

    Auto_thresholding_clustering: 13 Copyright 2011: Paul F. Whelan.