Last unit: heat flow is a Gaussian blur, built step by step. A blur removes noise and edges. Now we let the image decide how much heat may flow (Perona & Malik, 1990).
Edge-stopping: the conductivity g falls where the gradient is large; a contrast parameter K separates noise from edges.
Backward diffusion: edges steeper than K get sharper.
The prices: staircases on ramps, spikes that never go, and the cure: compute g from a slightly smoothed image.
When to stop: the stopping time is a regularisation parameter.
Slides titled The math give the formulas and proofs; the ideas are complete without them.
Differences much smaller than K: g \approx 1, treated as noise.
Differences much larger than K: g \approx 0, treated as edges.
g_1 stops more sharply; g_2 lets a little heat through even at strong edges.
K is a threshold in disguise, like the hysteresis thresholds of Canny: it has to sit between the typical noise difference and the typical edge height.
Perona–Malik as pseudocode
repeat for every step:
for every pixel p:
change = 0
for each of the 4 neighbours q:
d = I(q) − I(p) # outside: mirror border
change = change + g(|d|, K) · d # g = 1 gives the heat step
new(p) = I(p) + Δt · change
I = new
One line differs from the heat step: the flow is multiplied by g.
With pre-smoothing, |d| inside g is taken from the blurred image; the flow still uses d.
One step by hand
Row (10, 12, 10, 50, 50), g_2 with K = 5, \Delta t = 0.25, mirror border.
pair
difference
g_2
flow g \cdot d
1–2
2
0.862
1.72
2–3
−2
0.862
−1.72
3–4
40
0.015
0.62
4–5
0
1
0
Heat: (10.5, 11, 20.5, 40, 50): the step is already smeared.
Perona–Malik: (10.43, 11.14, 10.58, 49.85, 50): the small wiggle is smoothed, the step hardly moves.
The math: divergence form and flux
In 1D: u_t = \partial_x\big(\phi(u_x)\big) with the flux function\phi(s) = s\,g(|s|).
The explicit scheme on a grid: u_i \leftarrow u_i + \Delta t\,\big[\phi(u_{i+1} - u_i) - \phi(u_i - u_{i-1})\big]; what leaves one pixel enters its neighbour, so the total is kept (mirror border).
In 2D the same flux on each of the four pairs of neighbours (the original scheme of Perona and Malik). Since 0 \le g \le 1, the heat limit \Delta t \le 1/4 still applies.
Expanding the derivative: u_t = \phi'(u_x)\,u_{xx}: the local diffusion coefficient is \phi', not g. This is the key to the next slides.
Heat and Perona–Malik side by side
The noisy test card (\sigma_n = 12) under heat and under Perona–Malik (g_2, K = 10) for the same time.
Early (t = 1.8): heat already blurs every edge; Perona–Malik has removed the noise inside the regions and kept the square, the discs, the line.
Later: heat is a Gaussian blur of growing σ; Perona–Malik flattens each region, keeps the large contrasts, and removes the lattice and the stripes (their differences are too small).
Much later: everything merges, slowly. Insulation is never perfect.
Try it: edge-stopping diffusion
Backward diffusion: edges get sharper
Look at the flow\phi(s) = s\,g(s), not at g:
for small differences the flow grows with the difference: ordinary smoothing;
beyond s = K (g_2; K/\sqrt2 for g_1) it falls: a steeper edge lets less heat through.
Across a soft edge whose middle is steeper than K, the middle passes less heat than its gentler shoulders. The shoulders flatten, the heat piles up on both sides of the middle, and the middle gets steeper: heat flows “uphill”. This is backward diffusion, an un-blurring.
The histogram below: noise differences sit in the forward range, the step in the backward one.
Sharpening by hand
Row (0, 2, 6, 10, 12), g_2 with K = 2, \Delta t = 0.25. Differences 2, 4, 4, 2; flows \phi(2) = 1 (at the peak) and \phi(4) = 0.8 (past it).
After one step: (0.25, 1.95, 6, 10.05, 11.75). The shoulders moved towards each other (differences 2 → 1.7), the middle moved apart (4 → 4.05). A heat step would have done the opposite in the middle.
The math: where the switch happens
g_2: \phi(s) = \dfrac{s}{1 + s^2/K^2}, \phi'(s) = \dfrac{1 - s^2/K^2}{(1 + s^2/K^2)^2} < 0 \iff s > K.
Where \phi' < 0, u_t = \phi'(u_x)\,u_{xx} is a backward heat equation: a mode e^{i\omega x} grows like e^{|\phi'|\omega^2 t}. Ill-posed: the finest wiggles grow fastest.
In 2D, split at an edge pixel into the gradient direction η and the level-line direction ξ: u_t = g(|\nabla u|)\,u_{\xi\xi} + \phi'(|\nabla u|)\,u_{\eta\eta}. Along the edge it always smooths (g > 0); across it, it smooths or sharpens.
Price 1: staircases
A ramp whose slope is larger than K sits in the backward range everywhere. Tiny noise decides where it starts to sharpen first; neighbouring parts sharpen into separate small edges, the parts in between flatten.
The ramp breaks into terraces: a staircase, at random places.
A ramp gentler than K is smoothed (forward range), so K also decides which slopes count as “edges”.
TV, in the next unit, has the same artefact for a different reason.
Try it: sharpening and staircases in 1D
Price 2: ill-posed, and the cure
Backward diffusion amplifies whatever is steep, including noise:
an isolated spike higher than about K is seen as an edge: its flux is almost zero, so it is kept (with g_1, forever);
noisy pixels with large differences can sharpen into speckles instead of being smoothed.
The result depends on tiny details of the input, and on the grid.
Cure (Catté, Lions, Morel & Coll, 1992): compute g from a slightly smoothed image, g\big(|\nabla(G_\sigma * u)|\big), with σ about 1 (the Canny σ). A single-pixel spike has no large gradient after smoothing, a real edge still does.
The math: maximum principle and well-posedness
In 1D the explicit step is u_i \leftarrow (1 - \Delta t\,(g_{i-\frac12} + g_{i+\frac12}))\,u_i + \Delta t\,g_{i-\frac12}\,u_{i-1} + \Delta t\,g_{i+\frac12}\,u_{i+1}. With 0 \le g \le 1 and \Delta t \le 1/2 all weights are \ge 0 and sum to 1: a convex combination, no new extrema (in 2D: \Delta t \le 1/4).
So the discrete scheme is stable even where the continuous PDE is ill-posed: the grid itself regularises it, and the result depends on the pixel size.
With g computed from G_\sigma * u the problem has a unique solution that depends continuously on the input (Catté et al., stated without proof).
When to stop?
Perona–Malik has no steady state worth having: insulation is never perfect (g > 0), so if you run forever every region drifts to the mean of the image.
The stopping time is a regularisation parameter, like λ or the number of iterations in the deconvolution day (stopping early regularises):
too early: noise left;
too late: small regions and fine detail merged;
the PSNR against time has a maximum (here 34.5 dB at t \approx 2.3, from 26.5 dB). On this card the heat equation hardly helps: from its first step on, its PSNR only falls, because the fine detail it blurs costs more than the noise it removes.
Choosing K and the other knobs
K between noise and edges: with noise \sigma_n, differences of two noisy neighbours have spread \sqrt2\,\sigma_n. For \sigma_n = 5 that is about 7; edges of 40 should be stopped: K \approx 10–15 gives g_2 \approx 0.8 for typical noise differences and \approx 0.1 at the edges.
Pre-smoothing σ: about 1 pixel; larger σ also moves edges and merges close ones (as in Canny).
Time step: the heat limit, \Delta t \le 1/4 in 2D, because g \le 1.
Stopping time: grows with the noise. In the demo with K = 10: best at t \approx 0.9 for \sigma_n = 6, 2.3 for 12, 5.4 for 24.
Image libraries usually call this filter “anisotropic diffusion”.
Isotropic or anisotropic?
Perona and Malik called their method anisotropic diffusion. Strictly it is not: the conductivity is one number per pixel, and the flow still points down the gradient. It is better called nonlinear isotropic diffusion.
True anisotropy smooths along an edge but not across it: the conductivity becomes a 2 × 2 tensor built from the structure tensor (edge- and coherence-enhancing diffusion; it closes gaps in fibres and membranes).
The 2D math slide shows that even the scalar version treats the two directions differently through \phi'; that is where the name comes from.
The same edge-stopping g appears in the level-set day (geodesic active contours): there it slows a moving front at edges, here it stops heat.
Summary
Perona–Malik: u_t = \nabla\cdot(g(|\nabla u|)\nabla u), a heat flow with an edge-stopping conductivityg_1 or g_2 and a contrast parameter K.
Differences below K are smoothed as noise; above K the flux falls and edges are kept or even sharpened (backward diffusion).
The prices: ramps steeper than K become staircases; isolated spikes survive; the continuous problem is ill-posed. Computing g from a slightly smoothed image fixes the worst of it.
There is no useful steady state: the stopping time regularises, and the best one grows with the noise.
Explicit steps need the same limit as heat: \Delta t \le 1/4 in 2D.