A binary image x (pixels ±1) is observed as y with every pixel flipped independently with a small probability. The Ising model links each pixel to its four neighbours and to its observed value through the energy E(x, y) = h Σi xi − β Σi~j xixj − η Σi xiyi, and p(x | y) ∝ exp(−E). ICM (iterated conditional modes) visits the pixels in raster order and gives each the sign of lower energy, so the energy can only go down, but it stops at a local minimum. Gibbs sampling draws each pixel from its conditional instead. The lower right panel is the exact most probable image, found by a minimum graph cut.
The image (150 × 200 pixels) is our own: the words “Graphical models” in a box, the same as in Figure 8.30 of the Python code. Book: β = 1.0, η = 2.1, h = 0, 10% noise. The graph cut is the exact minimiser of the energy (Greig, Porteous and Seheult 1989): it is recomputed whenever the parameters or the noise change.
code/ch08_graphical_models.py (functions ising_energy, icm, gibbs_ising, graph_cut_map, make_binary_image; Figure 8.30) and the checks in code/checks_ch08.py (ICM never raises the energy; the graph cut equals the brute-force minimum on small images).