The Perona-Malik equation:
∂I(x, y, t)/∂t = div[g(|∇I|) · ∇I]
Here I(x, y, t) is the evolving image (note the explicit time variable — the image is a function of space and "diffusion time"), ∇I is the 2D spatial gradient (∂I/∂x, ∂I/∂y), and div is the divergence operator (∂/∂x · v_x + ∂/∂y · v_y). The conductance g takes the gradient magnitude and returns a scalar between 0 and 1; the standard exponential form is g(s) = exp(−s²/K²).
Expanding the divergence:
∂I/∂t = ∂/∂x [g(|∇I|) · ∂I/∂x] + ∂/∂y [g(|∇I|) · ∂I/∂y]
The discretization on a 4-neighbor stencil approximates each term by central finite differences. With a time step λ, an iteration of forward Euler is:
I^{t+1}(x, y) = I^t(x, y) + λ · [g(∇N) · ∇N + g(∇S) · ∇S + g(∇E) · ∇E + g(∇W) · ∇W]
where ∇N = I(x, y−1) − I(x, y), and analogously for south/east/west. Each direction is treated independently; the conductance is evaluated separately for each neighbor based on the directed difference. Stability for this scheme requires λ ≤ 0.25 — the standard CFL condition for explicit diffusion schemes.
The mathematical content of the conductance function: g(s) = exp(−s²/K²) has a Gaussian shape in s, dropping smoothly from 1 to 0 as s grows. At s = K, g = 1/e ≈ 0.37. At s = 2K, g ≈ 0.018 — diffusion is essentially zero. K is the natural scale separating the two regimes. The alternative Lorentzian form g(s) = 1/(1 + (s/K)²) has a heavier tail (drops more slowly past K), producing slightly more diffusion across moderate edges. Both forms have the same asymptotic behavior at s = 0 and s = ∞; the choice between them changes the character of diffusion at intermediate gradients.
An interesting theoretical point: the original Perona-Malik formulation is ill-posed in the continuous limit — the equation admits non-unique solutions and can develop instabilities. Practical implementations rely on the discretization providing implicit regularization; a more principled approach uses the Catté regularization, evaluating the conductance on a Gaussian-smoothed gradient instead of the raw gradient, which makes the problem well-posed without much practical effect on the output for reasonable noise levels.