Quiz: segmentation as energy minimisation

Short questions to test your understanding. Try each on paper first, then open the answer. Throughout, labels are 1 (object) and 0 (background), and the energy is E(L) = \sum_p D_p(L_p) + \lambda \sum_{(p,q)} w_{pq}[L_p \ne L_q].


Q1. Why does thresholding a noisy image give isolated wrong pixels, and why does the smoothness term remove them?

What information does thresholding use for one pixel? What does an isolated pixel cost in the smoothness term?

Thresholding looks at each pixel’s own intensity only. With noise, some background pixels are brighter than the threshold (and some object pixels darker), and nothing stops them from getting the wrong label. An isolated wrong pixel disagrees with all 4 neighbours, which costs 4\lambda (with w = 1). Flipping it removes that cost and adds only the difference of its data costs, which is small for a pixel close to the threshold. So for large enough \lambda it flips.


Q2. Background pixels are \mathcal N(40, s^2) and object pixels \mathcal N(200, s^2), and D_p(\ell) = -\log P(I_p \mid \ell). At which grey level does \lambda = 0 put the threshold? Does it depend on s?

Set D_p(0) = D_p(1). The normalising constants of the two Gaussians are equal.

(I - 40)^2 = (I - 200)^2 gives I = 120, halfway between the means. It does not depend on s, as long as both classes have the same s. With different widths, or with a prior that one class is more common, the crossing point moves.


Q3. What do \lambda = 0 and a very large \lambda give?

Which term dominates in each case?

\lambda = 0: only the data term counts, each pixel takes its cheaper label: plain thresholding. Very large \lambda: any boundary costs more than the data can save, so the minimum has no boundary: all pixels get the same label, whichever has the smaller total data cost.


Q4. In a 1D profile, a real structure is 2 samples wide and each of its samples saves 3 units of data cost when labelled object. Above which \lambda does the optimal labelling remove it?

Keeping it inside the background costs two boundaries.

Keeping it saves 2 \cdot 3 = 6 in data and costs 2 boundaries, 2\lambda. It disappears when 2\lambda > 6, i.e. \lambda > 3. Thin structures are the first casualties of a large \lambda: their data gain grows with their area, their boundary cost does not shrink.


Q5. How many labellings does a 512 \times 512 image have? Why is that not a problem on a single row of pixels?

On a row, the best labelling of the first k pixels only depends on the label of pixel k.

2^{262144}, far beyond enumeration. On a row (a chain), dynamic programming keeps only two numbers per pixel, C_k(0) and C_k(1), the best energy of the first k pixels ending in each label. Each step looks at the previous two, so the cost is O(n). On a 2D grid, a pixel has neighbours in several directions that are linked through loops, and this bookkeeping breaks down.


Q6. Show that -\log of P(L \mid I) \propto P(I \mid L)\,P(L) gives E(L) when P(I \mid L) = \prod_p P(I_p \mid L_p) and P(L) \propto \exp(-\lambda \sum w_{pq}[L_p \ne L_q]).

\log turns products into sums.

-\log P(L \mid I) = -\sum_p \log P(I_p \mid L_p) + \lambda \sum w_{pq}[L_p \ne L_q] + \text{const} = \sum_p D_p(L_p) + \lambda\sum w_{pq}[L_p \ne L_q] + \text{const}. The constant (normalisation) does not depend on L, so the most probable labelling is the one with the smallest energy.


Q7. The smoothness term uses w_{pq} = 1 for every pair of neighbours. What would you change to make the boundary prefer to follow the edges of the object?

Where should a boundary be cheap?

Make w_{pq} small where the intensities of p and q differ a lot, for example w_{pq} = \exp\!\big(-(I_p - I_q)^2/2\sigma^2\big). A boundary between two very different pixels is then almost free, and the minimum-energy boundary is pulled onto the image edges. This is the weight used in graph-cut segmentation.