This action might not be possible to undo. Are you sure you want to continue?
• Based on a very simple idea: Find the threshold that minimizes the weighted within-class variance. • This turns out to be the same as maximizing the between-class variance. • Operates directly on the gray level histogram [e.g. 256 numbers, P(i)], so it’s fast (once the histogram is computed).
• Assumes stationary statistics. • No use of spatial coherence. . but can be modified to be locally adaptive.Otsu: Assumptions • Histogram (and the image) are bimodal. so the bimodal brightness behavior arises from object appearance differences only. nor any other notion of object structure. (exercises) • Assumes uniform illumination (implicitly).
The weighted within-class variance is: σ (t) = q (t)σ (t) +q2 (t)σ (t) 1 2 w 2 1 2 2 Where the class probabilities are estimated as: q1 (t) = ∑ P(i) i =1 t q2 (t) = i = t +1 ∑ P(i) I I And the class means are given by: iP(i) µ1 (t) = ∑ i =1 q1 (t) t iP(i) µ2 (t) = ∑ i =t +1 q2 (t ) .
All we need to do is just run through the full range of t values [1.256] and pick the 2 value that minimizes σ w (t) . But the relationship between the within-class and betweenclass variances can be exploited to generate a recursion relation that permits a much faster calculation. . the individual class variances are: P(i) σ (t) = ∑[i − µ1 (t)] q1 (t) i=1 2 1 2 t P(i) σ (t) = ∑ [i − µ 2 (t)] q2 (t) i =t +1 2 2 2 I Now.Finally. we could actually stop here.
. but the basic idea is that the total variance does not depend on threshold (obviously). which is the sum of weighted squared distances between the class means and the grand mean. • For any given threshold. the total variance is the sum of the within-class variances (weighted) and the between class variance.Between/Within/Total Variance • The book gives the details.
σ B (t) Since the total is constant and independent of t. minimizing the within-class variance is the same as maximizing the between-class variance. in . The nice thing about this is that we can compute the quantities 2 σ B (t) recursively as we run through the range of t values.. the effect of changing the threshold is merely to move the contributions of the two terms back and forth. from before 2 Between-class.After some algebra. we can express the total variance as. So.. σ = σ (t) + q1 (t)[1 − q1 (t)][µ1 (t) − µ2 (t)] 2 2 w 2 Within-class.
q1 (1) = P(1) . q1 (t + 1) = q1 (t) + P(t + 1) q1 (t) µ1 (t) + (t + 1)P(t + 1) µ1 (t + 1) = q1 (t + 1) µ − q1 (t + 1)µ1 (t + 1) µ2 (t + 1) = 1 − q1 (t + 1) .....Finally.. Initialization. µ1 (0) = 0 Recursion..