Quiz: smoothing as heat flow
Before this unit: Day 5: Deconvolution; Day 2: Edges, blobs and ridges.
See also: Day 28: Ising model and Markov random fields; Day 31: Level sets.
Short questions to test your understanding. Try each on paper first, then open the answer. One explicit step: u \leftarrow u + \Delta t\,(\text{sum of the neighbours} - (\text{number of neighbours})\,u), pixel size 1.
Q1. A 1D row (0, 6, 0) with a mirror border. What is it after one explicit step with \Delta t = 1/4? What is the total before and after?
With a mirror border, the end pixels have only one neighbour that differs from them.
Left end: 0 + \tfrac14(6 - 0) = 1.5; centre: 6 + \tfrac14(0 + 0 - 12) = 3; right end 1.5. The row becomes (1.5, 3, 1.5); the total is 6 before and after. Heat has moved from the centre to its neighbours, none has left.
Q2. You run the heat equation u_t = \Delta u for a time t = 8. Which Gaussian blur gives the same image? How long must you run for twice that σ?
\sigma = \sqrt{2t}.
\sigma = \sqrt{16} = 4. For \sigma = 8 you need t = \sigma^2/2 = 32: four times as long. Time grows with the square of σ.
Q3. In 2D, someone takes explicit steps with \Delta t = 0.4. What will they see, and why?
Compare with the limit \Delta x^2/(2d).
The 2D limit is 1/4. With \Delta t = 0.4 the centre weight is 1 - 4 \cdot 0.4 = -0.6: every pixel gives away more than it has. The finest checkerboard pattern (present in any noise) is multiplied by 1 - 8 \cdot 0.4 = -2.2 per step, so after a few steps the image is covered by a growing checkerboard and the values explode.
Q4. Why does nobody blur with σ = 10 by explicit heat steps, although the result is the same as a Gaussian blur?
Count the steps at the largest stable \Delta t in 2D.
t = \sigma^2/2 = 50, and \Delta t \le 1/4, so at least 200 steps, each touching every pixel and its 4 neighbours. A separable Gaussian with σ = 10 needs 2 × 81 multiplications per pixel in one pass. The PDE is worth it only when the rule depends on the image (a conductivity per pixel, or an update inside a hole only).
Q5. A microscope image is resampled to half the pixel size. You want the same physical amount of diffusion. How does the number of explicit steps change in 2D, and how does the total work change?
The limit is \Delta t \le \Delta x^2/4; the time needed in physical units stays the same.
Halving \Delta x makes the allowed step 4 times smaller, so 4 times as many steps. Each step also touches 4 times as many pixels: 16 times the work. (A moving front, whose limit is proportional to \Delta x, would need only 2 times the steps.)
Q6. What does an implicit step buy, and what does it cost?
(I + \Delta t L)\,u^{\text{new}} = u^{\text{old}}.
It is stable for any \Delta t (every mode is damped by 1/(1 + \Delta t\lambda), never amplified, never sign-flipped), so a large amount of smoothing needs few steps. The cost is solving a sparse linear system per step instead of a simple update. A very large step is stable but not accurate in time: it is one big smoothing, not the exact heat flow.
Q7. With a zero border, the total of the image falls over time; with a mirror border it does not. Where does the heat go in the first case?
What value does the zero border pretend lies outside the image?
The zero border holds the outside at 0, so border pixels with positive values keep sending heat out of the image (a flux into a cold reservoir). The mirror border copies the border pixel outward: the difference across the border is 0, so nothing flows out.
Q8. (math) Show that the 1D explicit step is a weighted average of the old values when r = \Delta t/\Delta x^2 \le 1/2, and conclude that no new maximum can appear.
Write u_i^{n+1} = r\,u_{i-1}^n + (1 - 2r)\,u_i^n + r\,u_{i+1}^n.
The weights r, 1 - 2r, r sum to 1 and are all \ge 0 when r \le 1/2. A weighted average with non-negative weights lies between the smallest and the largest of the values averaged, so \min u^n \le u_i^{n+1} \le \max u^n: the maximum can only fall and the minimum only rise. For r > 1/2 the centre weight is negative and the step extrapolates.