Quiz: filling holes
Before this unit: Neighbourhood filters in depth: bilateral and non-local means (previous 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. Harmonic inpainting: each missing pixel is the mean of its neighbours; TV inpainting: minimise the total variation in the hole; exemplar inpainting: copy the best-matching patch.
Q1. Known values 0 and 12 with three missing pixels between them (1D). What does harmonic inpainting give?
In 1D the mean of the two neighbours: linear interpolation.
3, 6, 9: a straight line from 0 to 12. Each value is the mean of its two neighbours.
Q2. Why does Jacobi iteration need about four times as many sweeps for a hole twice as wide?
Jacobi is the heat equation inside the hole.
A Jacobi sweep is an explicit heat step with Δt = 1/4. Information spreads like heat: over a distance w in a time \propto w^2. Twice the width, four times the sweeps (in the demo: 77, 288 and 1081 sweeps for holes of width 8, 16 and 32).
Q3. A dark bar 6 pixels wide is interrupted by a gap of 4 pixels, another by a gap of 10. Which does TV inpainting reconnect?
Compare the edge length of “connect” (2d) with that of “break” (2w).
Gap 4 < width 6: connecting costs 2 \cdot 4 = 8 units of edge, breaking 2 \cdot 6 = 12: reconnected. Gap 10 > 6: connecting costs 20, breaking 12: left broken.
Q4. Which method for (a) a dead column in a fluorescence image, (b) a 40 × 40 hole in a textured region, (c) a hole crossed by one straight membrane?
Thin and smooth, texture, edges.
- Harmonic: a one-pixel-wide interpolation. (b) Exemplar: only copying reproduces texture; diffusion would leave a smooth smear. (c) TV (or exemplar with a strong data term): the membrane’s edge is continued sharply across the hole, if the hole is not much longer than the membrane is wide; otherwise exemplar or a curvature-based method.
Q5. Why does exemplar inpainting fill edges before texture?
What does the data term of the priority measure?
The priority is confidence × data term, and the data term is large where a strong isophote (edge) runs into the hole. Such front pixels are filled first, so the edge is extended into the hole before the texture around it closes it off.
Q6. A colleague inpaints a burnt-in scale bar and then measures the mean intensity of a region the bar crossed. What is wrong, and what should be done instead?
Where do the inpainted values come from?
The inpainted pixels are guesses from a prior (smoothness, copies), not measurements: they pull the mean towards the surroundings or towards whatever was copied. Measure on the original with the bar’s pixels masked (excluded), and report the masked area.
Q7. Exemplar inpainting produced a convincing nucleus inside a hole. How can that happen when the hole was empty?
What does the method know about the hole’s contents?
Nothing: it only matches the known pixels at the rim. If the rim resembles the edge of a nucleus (or of anything frequent in the image), the best-matching patches come from nuclei, and copying continues the “nucleus” into the hole. Plausibility is not evidence.
Q8. (math) Write the linear system of harmonic inpainting for two neighbouring missing pixels a, b whose other neighbours are 10, 10, 10 (for a) and 30, 30, 30 (for b), and solve it.
Each missing pixel: 4 × itself = sum of its four neighbours.
\begin{pmatrix}4 & -1\\-1 & 4\end{pmatrix}\begin{pmatrix}a\\b\end{pmatrix} = \begin{pmatrix}30\\90\end{pmatrix}, so a = (120 + 90)/15 = 14, b = (360 + 30)/15 = 26.