Exercise: choosing the threshold from the histogram

Goal

By the end of this exercise you should be able to:

  • compute Otsu’s threshold by hand from a small histogram, and check that total = within + between,
  • run isodata by hand, and recognise when it stops at a different split than Otsu,
  • find the minimum-error (Bayes) threshold of two normal classes, and say which way it moves from the midpoint,
  • predict from the shape of a histogram which method is biased, and in which direction.

Do the pen-and-paper part first, then the three demos. Questions marked (math) are for those who want the derivations; the concept questions do not depend on them.

Background

Symbol Meaning
Class 0, class 1 grey levels i \le t (background) and i > t (object)
\omega_0, \omega_1 class weights: fractions of the pixels; \omega_0 = P(t)
\mu_0, \mu_1; \sigma_0^2, \sigma_1^2 class means and variances
\sigma_W^2 within-class variance \omega_0\sigma_0^2 + \omega_1\sigma_1^2
\sigma_B^2 between-class variance \omega_0\omega_1(\mu_0 - \mu_1)^2; \sigma_T^2 = \sigma_W^2 + \sigma_B^2
Otsu $t^* = $ the t with the largest \sigma_B^2
Isodata repeat t \leftarrow (\mu_0 + \mu_1)/2
Bayes threshold where \omega_0 f_0(t) = \omega_1 f_1(t); equal variances: t = \frac{\mu_0 + \mu_1}{2} + \frac{\sigma^2}{\mu_1 - \mu_0}\ln\frac{\omega_0}{\omega_1}

By hand

The worked example of the lecture: grey levels 0–7 with counts h = (2, 5, 3, 1, 1, 2, 4, 2), N = 20, \mu = 3.3, \sigma_T^2 = 5.81.

B1. Otsu’s table. (a) Compute \omega_0, \mu_0, \mu_1 and \sigma_B^2 = \omega_0\omega_1(\mu_0 - \mu_1)^2 for t = 2, t = 3 and t = 4. (b) Given \sigma_B^2 = 1.21, 3.60, \cdot, \cdot, \cdot, 3.94, 1.52 for the other t, which t does Otsu choose? Which pixels are object?

B2. Isodata on the same histogram. (a) Start at t = 5.5 (class 0 = levels 0–5). Compute \mu_0, \mu_1 and the new t. Do one more step. (b) Where does it stop? Compare with B1.

B3. Three groups: counts h = (9, 0, 0, 8, 7, 0, 0, 5) for levels 0–7 (29 pixels). (a) Run isodata from t = 6.5. Where does it stop? (b) Compute \sigma_B^2 for the split \{0\} \mid \{3, 4, 7\} and for \{0, 3, 4\} \mid \{7\}. Which one does Otsu choose? (c) Run isodata from t = 0.5. What does this tell you about isodata?

B4. Two classes with normal grey levels: background \mu_0 = 50, objects \mu_1 = 150, both \sigma = 20; objects are 10 % of the pixels. (a) Compute the Bayes threshold. Does it lie above or below the midpoint 100? Explain in words why. (b) What is the threshold when the objects are 50 % of the pixels? (c) Isodata and Otsu ignore the weights. Which way would you expect them to err for 10 % objects, and why?

B5. Unequal widths: background \mu_0 = 80, \sigma_0 = 12; objects \mu_1 = 150, \sigma_1 = 40, \omega_1 = 0.4. The weighted densities cross at 40.8 and 105.4. (a) Sketch the two weighted curves. Which class wins (has the larger weighted density) below 40.8, between 40.8 and 105.4, and above 105.4? (b) Is a single threshold the best possible rule here? What is the best rule?

B6. For each histogram shape, name a method that suits it and one that fails: (a) two well-separated peaks of similar size and width; (b) a large dark background peak and a small, long bright tail (a few fluorescent spots); (c) three peaks (background, cytoplasm, nucleus); (d) two peaks that overlap so much that there is no dip between them.

B1. (a) t = 2: class 0 has 2 + 5 + 3 = 10 pixels with sum 0 + 5 + 6 = 11: \omega_0 = 0.50, \mu_0 = 1.10; class 1 has 10 pixels with sum 66 - 11 = 55: \mu_1 = 5.50; \sigma_B^2 = 0.5 \cdot 0.5 \cdot 4.4^2 = 4.84. t = 3: 11 pixels, sum 14: \omega_0 = 0.55, \mu_0 = 1.27; class 1: 9 pixels, sum 52, \mu_1 = 5.78; \sigma_B^2 = 0.55 \cdot 0.45 \cdot 4.51^2 = 5.02. t = 4: 12 pixels, sum 18: \omega_0 = 0.60, \mu_0 = 1.50; class 1: 8 pixels, sum 48, \mu_1 = 6.00; \sigma_B^2 = 0.6 \cdot 0.4 \cdot 4.5^2 = 4.86. (b) The largest is 5.02 at t^* = 3: object = grey levels 4–7, 9 pixels.

B2. (a) Class 0 = levels 0–5: 14 pixels, sum 28, \mu_0 = 2.00; class 1 = levels 6–7: 6 pixels, sum 38, \mu_1 = 6.33; new t = 4.17. Next: class 0 = levels 0–4: 12 pixels, \mu_0 = 1.50; class 1: \mu_1 = 6.00; t = 3.75. (b) Then class 0 = levels 0–3: \mu_0 = 1.27, \mu_1 = 5.78, t = 3.53, which gives the same split again: it stops at 3.53, the split \{0..3\} \mid \{4..7\}, the same as Otsu.

B3. (a) From 6.5: class 0 = \{0, 3, 4\}: 24 pixels, sum 0 + 24 + 28 = 52, \mu_0 = 2.17; class 1 = \{7\}: \mu_1 = 7; t = 4.58. The split is the same, so it stops at 4.58. (b) \mu = (24 + 28 + 35)/29 = 3.00. Split \{0\} \mid rest: \omega_0 = 9/29 = 0.31, \mu_0 = 0, \mu_1 = 87/20 = 4.35: \sigma_B^2 = 0.31 \cdot 0.69 \cdot 4.35^2 = 4.05. Split \{0, 3, 4\} \mid \{7\}: \omega_0 = 24/29 = 0.83, \sigma_B^2 = 0.83 \cdot 0.17 \cdot (7 - 2.17)^2 = 3.33. Otsu chooses \{0\} \mid \{3, 4, 7\}. (c) From 0.5: class 0 = \{0\}, \mu_0 = 0, \mu_1 = 4.35, t = 2.17; the split is the same, so it stops at 2.17, the Otsu split. Isodata finds a fixed point near its start: a local optimum. With two clear groups there is only one; with three groups there are several.

B4. (a) t = 100 + \frac{20^2}{100}\ln\frac{0.9}{0.1} = 100 + 4 \cdot 2.197 = 108.8, above the midpoint. Near the midpoint, a grey level is equally far from both means, but a random pixel is 9 times more likely to be background; the boundary moves towards the rarer class until the two weighted densities are equal. (b) \ln 1 = 0: t = 100, the midpoint. (c) They put t near the middle of the two class means, or lower: the large background class dominates, and a split that cuts into its tail barely changes \mu_0. They err towards the background (too low t), so many background pixels become object. (On these curves Otsu chooses 98.5.)

B5. (a) Below 40.8 the wide object class wins (its tail decays much more slowly than the narrow background peak), between 40.8 and 105.4 the background wins, above 105.4 the objects win. (b) No. The Bayes rule labels object both below 40.8 and above 105.4. A single threshold at 105.4 misses the (tiny) object tail below 40.8; in practice that tail is so small that the single threshold is nearly as good, but the rule is an interval, not a threshold.

B6. (a) Otsu, isodata and minimum error all work and agree; nothing fails badly (the triangle method is not made for this and lands lower). (b) Triangle or maximum entropy (or minimum error if the tail is roughly normal); Otsu and isodata fail, dragged into the big peak. (c) Multi-level Otsu with three classes; any two-class method has to merge two of the classes. (d) Every histogram method fails: the grey level alone cannot separate the classes. Smooth first, or use neighbours (graph cuts).

Math questions

B7. (math) Prove \sigma_T^2 = \sigma_W^2 + \sigma_B^2 (add and subtract the class mean inside the square), and then \sigma_B^2 = \omega_0\omega_1(\mu_0 - \mu_1)^2. Check both at t = 3 in the worked example (\sigma_0^2 = 0.744, \sigma_1^2 = 0.840).

B8. (math) With P = P(t) and M = M(t), show that \mu_1 - \mu_0 = (\mu P - M)/(P(1 - P)) and hence \sigma_B^2(t) = (\mu P - M)^2/(P(1 - P)).

B9. (math) Show that for continuous grey levels every stationary point of \sigma_B^2(t) satisfies t = (\mu_0 + \mu_1)/2 (Otsu’s optimum is an isodata fixed point).

B10. (math) Derive the equal-variance minimum-error threshold t = \frac{\mu_0 + \mu_1}{2} + \frac{\sigma^2}{\mu_1 - \mu_0}\ln\frac{\omega_0}{\omega_1} from E'(t) = 0. Then show that for unequal variances the condition is a quadratic equation in t.

B11. (math) Show that the average negative log-likelihood of the pixels, each assigned to its own side of t with a fitted normal distribution, is \tfrac12\ln 2\pi + \tfrac12 + \sum_k\omega_k\ln\sigma_k - \sum_k\omega_k\ln\omega_k (the Kittler–Illingworth criterion up to constants).

B7. \sum_{i \in k}(i - \mu)^2 p_i = \sum_{i \in k}\big((i - \mu_k) + (\mu_k - \mu)\big)^2 p_i = \sum_{i \in k}(i - \mu_k)^2 p_i + 2(\mu_k - \mu)\sum_{i \in k}(i - \mu_k)p_i + (\mu_k - \mu)^2\sum_{i \in k}p_i. The middle sum is \omega_k\mu_k - \mu_k\omega_k = 0. Summing over k: \sigma_T^2 = \sum_k \omega_k\sigma_k^2 + \sum_k\omega_k(\mu_k - \mu)^2. With \mu = \omega_0\mu_0 + \omega_1\mu_1 and \omega_0 + \omega_1 = 1: \mu_0 - \mu = \omega_1(\mu_0 - \mu_1), \mu_1 - \mu = \omega_0(\mu_1 - \mu_0), so \sigma_B^2 = \omega_0\omega_1^2 d^2 + \omega_1\omega_0^2 d^2 = \omega_0\omega_1 d^2 with d = \mu_0 - \mu_1. At t = 3: \sigma_W^2 = 0.55 \cdot 0.744 + 0.45 \cdot 0.840 = 0.787, \sigma_B^2 = 5.023, sum 5.81 = \sigma_T^2.

B8. \mu_0 = M/P and \mu_1 = (\mu - M)/(1 - P) (the total first moment is \mu). Then \mu_1 - \mu_0 = \frac{P(\mu - M) - M(1 - P)}{P(1 - P)} = \frac{\mu P - M}{P(1 - P)}, and \sigma_B^2 = P(1 - P)(\mu_1 - \mu_0)^2 = \frac{(\mu P - M)^2}{P(1 - P)}.

B9. With density p: P' = p(t), M' = t\,p(t), D = \mu P - M, D' = (\mu - t)p(t). \frac{d}{dt}\frac{D^2}{P(1 - P)} = \frac{2DD'P(1 - P) - D^2(1 - 2P)p}{P^2(1 - P)^2} = 0 gives (for p(t) \ne 0, D \ne 0) 2(\mu - t)P(1 - P) = D(1 - 2P). With D = P(1 - P)(\mu_1 - \mu_0): t = \mu - \frac12(1 - 2P)(\mu_1 - \mu_0), and inserting \mu = P\mu_0 + (1 - P)\mu_1 gives t = P\mu_0 + (1 - P)\mu_1 - \frac12(\mu_1 - \mu_0) + P(\mu_1 - \mu_0) = \frac12(\mu_0 + \mu_1).

B10. E'(t) = -\omega_0 f_0(t) + \omega_1 f_1(t) = 0. With normal densities, take logs: \ln\omega_0 - \ln\sigma_0 - \frac{(t - \mu_0)^2}{2\sigma_0^2} = \ln\omega_1 - \ln\sigma_1 - \frac{(t - \mu_1)^2}{2\sigma_1^2}. For \sigma_0 \ne \sigma_1 the t^2 terms have different coefficients: a quadratic at^2 + bt + c = 0 with a = \frac1{2\sigma_1^2} - \frac1{2\sigma_0^2}. For \sigma_0 = \sigma_1 = \sigma they cancel: (t - \mu_1)^2 - (t - \mu_0)^2 = (\mu_0 - \mu_1)(2t - \mu_0 - \mu_1) = 2\sigma^2\ln\frac{\omega_1}{\omega_0}, so t = \frac{\mu_0 + \mu_1}{2} + \frac{\sigma^2}{\mu_1 - \mu_0}\ln\frac{\omega_0}{\omega_1}.

B11. -\sum_i p_i\ln\big(\omega_k f_k(i)\big) = -\sum_k\sum_{i \in k}p_i\Big(\ln\omega_k - \ln\sigma_k - \tfrac12\ln 2\pi - \frac{(i - \mu_k)^2}{2\sigma_k^2}\Big). Use \sum_{i \in k}p_i = \omega_k and \sum_{i \in k}p_i(i - \mu_k)^2 = \omega_k\sigma_k^2: = -\sum_k\omega_k\ln\omega_k + \sum_k\omega_k\ln\sigma_k + \tfrac12\ln 2\pi + \sum_k\frac{\omega_k\sigma_k^2}{2\sigma_k^2}, and the last sum is \tfrac12.

Explore: Otsu by hand

The eight bars are a histogram; drag a bar up or down to change its count (0–9). The threshold t (slider, or click a row of the table) colours class 0 blue and class 1 orange; the dots under the bars are the class means. The table lists \omega_0, \mu_0, \mu_1 and \sigma_B^2 for every t (★ = Otsu). The bar below the plot splits the total variance into within and between. isodata step moves the isodata threshold (dashed) to the midpoint of the class means.

P1. Preset the worked example. Check your B1 table. Move t from 0 to 6: what happens to the total, the within and the between part?

P2. Press isodata step three times and compare with B2. Then preset isodata stuck: press isodata step until it stops, and compare with B3.

P3. Preset two equal peaks. Where is Otsu’s threshold, and why? Now drag the bar at level 7 up to 9. Does t^* move?

P4. Preset a tiny object class: the objects are the 2 pixels at level 7. Which split does Otsu choose? Is that the split you want? What does isodata give from 5.5?

P1. The table matches B1: t^* = 3 with \sigma_B^2 = 5.02. The total stays at 5.81 for every t; the within part is smallest (0.79) exactly where the between part is largest (5.02), and both trade off as t moves.

P2. From 5.5: 4.17, 3.75, 3.53, then it stops at the split of t = 3, as in B2. Stuck: 6.5 → 4.58, and then 4.58 again: it stops at split 4 with \sigma_B^2 = 3.33, while the star (Otsu) is at t = 0 with 4.05 (the rows t = 0, 1, 2 tie, because levels 1 and 2 are empty).

P3. t^* = 3, with \sigma_B^2 = 3.27: the histogram (1, 4, 6, 2, 2, 6, 4, 1) is symmetric about 3.5, so the best split is in the middle. Raising h_7 to 9 makes the histogram asymmetric, but t^* stays at 3 (\sigma_B^2 = 4.29, just ahead of 4.26 at t = 4): the extra bright pixels raise \mu_1 for every split, and the middle remains the best place to cut.

P4. Otsu splits at t = 3: levels 4–7 (6 pixels: three 4s, one 5 and the two 7s) are called object. It cuts into the tail of the big peak, because a class of 2 pixels out of 32 contributes little to \sigma_B^2 (at t = 6, \sigma_B^2 = 1.45 against 1.84 at t = 3). Isodata from 5.5 goes to 4.52 and stops at 4.13 (split 4): also inside the big peak.

Explore: two Gaussians and six thresholds

The image (right) is drawn from a two-class model: a blob-shaped object mask covering a fraction \omega_1 of the pixels, and for each pixel a grey level drawn from its class’s normal distribution \mathcal N(\mu_k, \sigma_k^2). Top left: the histogram of the image (grey), the weighted class densities \omega_0 f_0 (blue) and \omega_1 f_1 (orange), and the thresholds of Otsu, isodata, min-error (Kittler–Illingworth), triangle, Kapur (maximum entropy) and the Bayes boundary of the true model (dashed; the selected method solid). The shaded areas are the selected method’s errors: orange = object pixels it calls background, blue = background pixels it calls object. Below: the selected method’s criterion as a function of t. The table gives each method’s threshold and its error rate under the model; the caption above the image gives the wrong pixels in this image.

E1. Preset equal, well separated. Which methods agree, and on what threshold? Which one does not, and why?

E2. Preset unequal weights (\omega_1 = 0.1). Read Otsu’s threshold and error, and the Bayes threshold and error. Which way did Otsu move, and how does that match B4? Which histogram method comes closest to Bayes? Now raise \omega_1 to 0.3 and 0.5.

E3. Preset unequal variances. Where are the two Bayes crossings? Select min-error and Otsu: compare their thresholds and errors.

E4. Preset small object (3 %). Is the histogram bimodal? Compare the errors of Otsu, triangle, Kapur and min-error with Bayes. Select triangle and look at its criterion curve.

E5. Preset heavy overlap. What is the smallest possible error? What do the masks look like?

E6. Back to unequal weights: set the image size to 32² (1024 pixels) and to 256². Which methods change their threshold, and by how much?

E1. Otsu, isodata and min-error choose 125 and Kapur 124, all at the Bayes threshold 125.0 (error 0.1 %). The triangle method chooses 109 (error 1.2 %): it draws its line from the background peak to the end of the histogram and assumes a unimodal histogram with a tail, which this is not.

E2. Otsu: 85 with an error of 19.9 %; Bayes: 114.6 with 3.4 %. Otsu moved down, into the large background class, by about 30 grey levels, as predicted in B4. Min-error chooses 123 (4.1 %), Kapur 108 (3.9 %), triangle 105 (4.5 %): Kapur is closest in error here, min-error is the only one on the correct side of Bayes. At \omega_1 = 0.3: Otsu 97 (7.5 %) against Bayes 105.6 (6.0 %); at \omega_1 = 0.5 every method except the triangle chooses 100, the Bayes threshold (6.7 %).

E3. The weighted densities cross at 40.8 and 105.4; below 40.8 the wide object class wins again (B5). Min-error chooses 112 (7.2 %), close to the Bayes error of 6.2 %; Otsu chooses 125 (10.8 %): it ignores that the object class is wide and puts the threshold too far into it.

E4. No: the 3 % object class is a small shoulder on the right of one big peak. Otsu chooses 62, inside the background peak, with a disastrous 40.6 % error; isodata 64 (34.4 %). Triangle 91, Kapur 93 and min-error 98 all have about 1.4–1.5 %, close to Bayes (94.1, 1.4 %). The triangle criterion is the distance below the line from the peak to the end of the tail; it is largest where the background peak ends and the object tail begins.

E5. Bayes: 120.4 with 21.9 % error, the best any threshold can do: more than a fifth of the pixels are wrong whatever t is. Otsu and isodata (113, 23.2 %) and Kapur (123, 22.1 %) are close to it; min-error (173) and triangle (149) fail badly because the histogram is one hump. Every mask is speckled: the grey level of a single pixel simply does not tell the classes apart. Neighbouring pixels must help (smoothing, or graph cuts).

E6. At 32² the histogram is ragged: Otsu stays at 85, isodata 85, but the triangle method jumps from 105 to 85 (19.9 %), Kapur from 108 to 103 and min-error from 123 to 121. At 256² the curves are smooth: Otsu 84, triangle 114 (3.4 %), Kapur 107, min-error 123. Methods that look at the shape of the histogram (triangle, Kapur) need many pixels; Otsu’s means are stable even for small images (but biased).

Explore: Otsu on the micrograph

The same demo as in the last unit, now with Otsu’s criterion \eta(t) = \sigma_B^2(t)/\sigma_T^2 (between 0 and 1) on the lower plot, and the option of three classes (two thresholds t and t_2; multi-level Otsu).

C1. Untick 3 classes and press t = Otsu. What is Otsu’s threshold for the micrograph, and how large is \eta there? What does the mask separate?

C2. Tick 3 classes and press t = Otsu. Give t_1 and t_2. What do the three classes contain? Can any threshold separate the nucleus from the cytoplasm?

C3. Untick 3 classes, choose synthetic blobs, set noise σ to 20, and press t = Otsu. Compare Otsu’s Dice with the best Dice you can find by hand.

C1. t^* = 163 with \eta = 0.76: the split explains 76 % of the grey-level variance. It separates the bright empty background (above 163) from everything else (45.2 % of the pixels are at or below 163): the cell and the dark material around it.

C2. t_1 = 120, t_2 = 188. Darkest class (purple): membranes, dense granules and the darkest parts of the cell; middle class (orange): cytoplasm and nucleus together; brightest: empty background. The nucleus and the cytoplasm have overlapping grey levels, so no threshold separates them; their difference is texture and position, which the histogram does not see.

C3. Otsu chooses t = 106 with Dice 0.946; the best threshold is about 112 with Dice 0.951. With 25 % objects Otsu is slightly biased into the background, but the loss is small when the peaks are well separated.

Code

Write the algorithms of this unit yourself, in Rust. Setup, and how to run and check your code: coding exercises: getting started. Your code goes in thresholding/src/otsu/exercise.rs. The coding tasks are numbered R1, R2, …, because this page already uses C1, C2, … for the demo questions.

All functions work on a histogram h of counts, h[i] pixels with grey level i. Class 0 is the levels \le t, class 1 the levels above.

R1. class_stats(h, t): \omega_0, \mu_0 and \mu_1 for the split at t, in one loop over the levels. The check is B1 (a).

R2. otsu(h): try every split.

best = −1
for t = 0, 1, …, L − 2:
    ω0, μ0, μ1 = class_stats(h, t);   ω1 = 1 − ω0
    if a class is empty: skip this t
    σB² = ω0 · ω1 · (μ0 − μ1)²
    if σB² > best:  best = σB²;  t* = t
return t*

The checks are B1 (b) (t^* = 3) and B3 (b) (t^* = 0: the splits at 0, 1 and 2 tie, and the first wins).

R3. isodata(h, start):

t = start
repeat:
    μ0, μ1 = class means for the split at ⌊t⌋
    new = (μ0 + μ1) / 2
    if ⌊new⌋ = ⌊t⌋: return new       # the split no longer changes
    t = new

The checks are B2 (3.53 from 5.5) and B3 (4.58 from 6.5, 2.17 from 0.5).

R4. min_error(h): for every t, fit a normal distribution to each class (weight \omega_k, variance \sigma_k^2) and keep the t with the smallest J(t) = 1 + 2(\omega_0\ln\sigma_0 + \omega_1\ln\sigma_1) - 2(\omega_0\ln\omega_0 + \omega_1\ln\omega_1); skip splits where a class is empty or has variance 0. The check uses the expected histogram of B4: the minimum-error threshold lies near the Bayes threshold 108.8, Otsu’s near 98.

R5. otsu3(h): three classes, two thresholds t_1 < t_2; try all pairs and keep the largest \sum_k \omega_k(\mu_k - \mu)^2. Make running sums of the counts and of i\,h_i first, so that each class costs two subtractions.

Then cargo run -p thresholding -- otsu and open the pictures in out/otsu/. The program makes a two-class image as in B4 (background 50, objects 150, noise 20, about 9 % of the pixels object, the truth known), and thresholds it with each method; then it thresholds the micrograph.

R6. Compare the thresholds of Otsu, isodata and minimum error with the Bayes threshold of B4, and the fractions of wrong pixels. Which way does Otsu err, as predicted in B4 (c)? Where are its wrong pixels in two-classes-otsu.png?

R7. The micrograph: compare Otsu’s two- and three-class thresholds with the demo on the micrograph above (its first two questions). What do the three classes in cell-otsu3.png contain?

The model solution is thresholding/src/otsu/solution.rs in the download.

R6. Otsu chooses 98 and isodata 98.5, both below the Bayes threshold, into the large background class, as B4 (c) predicts (98.5 on the model curves). They get 0.81 % of the pixels wrong. Minimum error chooses 110, close to Bayes, with 0.34 % wrong, the same as a threshold at 108. Otsu’s extra errors are background pixels in the upper tail of the background peak: isolated white specks scattered over the background of two-classes-otsu.png.

R7. Otsu: 163; three classes: 120 and 188, the same as the demo. In cell-otsu3.png black is the darkest material (membranes, dense granules, the dark material outside the cell), grey is cytoplasm and nucleus together, white the bright empty background. The nucleus and the cytoplasm fall into the same class: their grey levels overlap.

Where this leads

Every method here looks at one pixel at a time and at one global histogram. The next unit drops both assumptions: the threshold may vary over the image (local thresholds), and a pixel’s decision may depend on its neighbours (hysteresis). The Bayes two-class model returns in graph cuts (day 27): its data term is exactly this unit’s -\log(\omega_k f_k), with a smoothness term added. Isodata grows into k-means and the two-Gaussian model into Gaussian mixtures fitted by EM (day 35), for many classes and many features; Otsu returns on the colour day to threshold a perceptual colour channel (day 46).