Fields, Seen Through Local Derivatives · Chapter 3
Hessian, Laplacian and Poisson reconstruction
Taking the Jacobian of the gradient gives the Hessian, and its trace gives the Laplacian. This chapter derives the second-order Taylor expansion, the link between the Laplacian and neighbourhood averages, and the second-order identities, then derives the Poisson surface reconstruction equation from a least-squares energy and shows where the Gauss–Newton approximation of the Hessian comes from.
Series contentsChapter 3 of 3
Series
Fields, Seen Through Local Derivatives- 01The Jacobian and the gradient: the derivative as a local linear map
- 02Divergence and curl: what they extract from the Jacobian
- 03Hessian, Laplacian and Poisson reconstruction
The question
What do we get by differentiating a field a second time? And why does the Laplacian show up in image edge detection, in diffusion equations and in point-cloud surface reconstruction alike?
Chapter 1 established that the derivative is a local linear map, and Chapter 2 that divergence and curl are information extracted from the Jacobian. This chapter applies the same idea at second order: the Hessian is the complete second-order information, and the Laplacian is one number extracted from it.
Intuition
The gradient says which way a scalar field tilts at a point, and how steeply. The Hessian says how that tilt itself changes: the local bending, whether the point sits like the bottom of a bowl, the top of a hill or the middle of a saddle.
The Laplacian adds up the bending over all directions and keeps one number. It has a more direct meaning: the difference between the value at a point and the average over its neighbourhood. A positive Laplacian means the neighbours are higher on average, so the centre sits in a dip; a negative one means the centre sits on a bump.
That meaning explains its many uses:
- in diffusion, points below their neighbours rise and points above them fall, so an image is smoothed;
- in edge detection, the second derivative changes sign where brightness changes sharply;
- in surface reconstruction, solving “the Laplacian equals a given function” stitches local gradient information into one global function.
Formalism
The Hessian is the Jacobian of the gradient
For a scalar field , the Hessian is the Jacobian of its gradient field:
When is twice continuously differentiable, mixed partials commute and is symmetric.
The second-order Taylor expansion shows what it means:
For a unit direction , is the second derivative along that direction. Because is symmetric it can be orthogonally diagonalized; its eigenvectors are the principal directions of curvature and its eigenvalues the second derivatives along them.
At a stationary point () the second-order term decides the local shape:
- positive definite, i.e. all eigenvalues positive: strict local minimum;
- negative definite: strict local maximum;
- indefinite, with eigenvalues of both signs: saddle point;
- semidefinite (some zero eigenvalue): second-order information alone usually cannot decide.
The Laplacian is the trace of the Hessian
This parallels “divergence is the trace of the Jacobian” exactly: divergence takes the trace of the Jacobian, the Laplacian takes the trace of the Hessian.
The Laplacian is isotropic. Rotate coordinates as with a rotation matrix . By the chain rule the Hessian in the new coordinates is , and the trace is invariant under this similarity:
The Laplacian does not depend on the orientation of the axes. This is one reason edge detectors favour it: it treats edges in every direction the same way.
The price is that all directional information is lost. For example has Hessian , which is not zero, yet . A zero Laplacian only says the bending in different directions cancels in the trace, not that the function is flat.
The Laplacian and neighbourhood averages
On a 2D grid with spacing , Taylor-expand in :
Adding the two cancels the odd-order terms:
Doing the same in and adding gives the five-point stencil:
“The sum of the four neighbours minus four times the centre” is times “the neighbour average minus the centre”.
Why diffusion smooths. The heat equation with raises points below their neighbourhood average and lowers points above it. With explicit Euler time stepping, one update reads
Choosing reduces the right-hand side to : each step replaces the centre with the average of its four neighbours. In 2D, is also the stability limit of the explicit scheme.
The distinction matters: the Laplacian operator does not blur an image by itself; the diffusion it drives does.
Second-order identities
Define the row-wise divergence of a matrix field as , and the component-wise Laplacian of a vector field as . Composing two operations gives:
| Operation | Result | Type |
|---|---|---|
| Divergence of a gradient, | Scalar | |
| Curl of a gradient, | Vector | |
| Jacobian of a gradient, | Matrix | |
| Divergence of a curl, | Scalar | |
| Gradient of a divergence, | Nonzero in general | Vector |
| Row-wise divergence of the Jacobian, | Vector | |
| Row-wise divergence of the transposed Jacobian, | Vector | |
| Curl of a curl, | Vector |
The two zero identities were proved in Chapter 2. The rows most easily confused are the middle two:
A single transpose changes the result. “The divergence of the Jacobian” and “the gradient of the divergence” are not interchangeable.
The curl of a curl. Write with the Levi-Civita symbol (repeated indices summed) and use :
The first term is and the second is , so .
Combined with the two row-wise divergences above, this can also be written
This echoes Chapter 2: encodes the curl, and taking its divergence gives the curl of the curl, up to a sign.
In robotics
Laplacian-of-Gaussian edge detection
Second derivatives of a raw image amplify noise, so the image is first smoothed with a Gaussian kernel . Differentiation and convolution are both linear and shift-invariant, so their order can be swapped (see Cross-correlation and convolution):
One convolution with a fixed Laplacian-of-Gaussian (LoG) kernel is enough. Marr and Hildreth (1980) took the zero crossings of the LoG response as edges.
The LoG also matters in scale space: extrema of the scale-normalized LoG give the location and scale of blobs. SIFT approximates the LoG by a difference of Gaussians (DoG) to detect keypoints (Lowe, 2004).
Poisson surface reconstruction
Given a point cloud with oriented normals, Poisson surface reconstruction (Kazhdan et al., 2006) seeks a scalar function whose level set is the reconstructed surface.
The starting observation is that the gradient of a smoothed indicator function (1 inside the object, 0 outside) is approximately the inward normal field near the surface and approximately zero elsewhere. So the normals are first interpolated into a vector field , and then we look for the function whose gradient is closest to it:
Variational derivation. For any smooth perturbation , differentiate at :
Let . The product rule together with the divergence theorem of Chapter 2 gives
If vanishes on the boundary (or the natural boundary condition holds), the boundary term drops. At a minimum the expression must vanish for every , so , that is,
This is the Poisson equation. The pipeline is “oriented normals → vector field → divergence → Poisson solve → implicit function → level set”, and gradient, divergence and Laplacian appear in turn. Kazhdan et al. solve the equation on an octree and use the average of at the sample points as the iso-value. Screened Poisson reconstruction (Kazhdan & Hoppe, 2013) adds point-position constraints to the energy to reduce over-smoothing. Libraries such as Open3D provide ready implementations.
Note that is a smoothed indicator function, not a signed distance function. Poisson reconstruction also differs from TSDF fusion: the former solves one global equation from an oriented point cloud, while the latter fuses depth observations frame by frame into a truncated distance representation.
The Hessian in pose optimization
Chapter 1 gave the gradient of the least-squares objective . Differentiating once more, component by component:
that is,
Gauss–Newton drops the second term and keeps only . The approximation is good when the residuals are small, or when the residual functions are nearly linear so that is small. Its advantages are that it needs only first derivatives and that is always positive semidefinite. Levenberg–Marquardt adds a damping term on top of it, so that it still converges stably when neither condition holds.
Experiment
The script checks four things in turn: the second-order identities with SymPy; the accuracy of the five-point stencil; diffusion as neighbourhood averaging; and a small 2D Poisson reconstruction.
import numpy as np
import scipy.sparse as sp
import scipy.sparse.linalg as spla
import sympy as s
# 1. second-order identities (for arbitrary smooth P, Q, R)
x, y, z = s.symbols("x y z")
v = [x, y, z]
F = s.Matrix([s.Function(n)(x, y, z) for n in "PQR"])
curl = lambda A: s.Matrix([A[2].diff(y) - A[1].diff(z),
A[0].diff(z) - A[2].diff(x),
A[1].diff(x) - A[0].diff(y)])
div = lambda A: sum(A[i].diff(v[i]) for i in range(3))
grad = lambda f: s.Matrix([f.diff(vi) for vi in v])
lap = lambda A: s.Matrix([sum(Ai.diff(vi, 2) for vi in v) for Ai in A])
Div = lambda M: s.Matrix([sum(M[i, j].diff(v[j]) for j in range(3)) for i in range(3)])
J = F.jacobian(v)
print(s.simplify(curl(curl(F)) - (grad(div(F)) - lap(F))).T) # [0, 0, 0]
print(s.simplify(Div(J) - lap(F)).T, s.simplify(Div(J.T) - grad(div(F))).T)
# 2. five-point stencil vs the analytic Laplacian
n = 201
h = 2.0 / (n - 1)
g = np.linspace(-1, 1, n)
Xg, Yg = np.meshgrid(g, g)
f = np.sin(np.pi * Xg) * np.cos(np.pi * Yg)
lap_exact = -2 * np.pi**2 * f
lap_5 = (f[1:-1, 2:] + f[1:-1, :-2] + f[2:, 1:-1] + f[:-2, 1:-1] - 4 * f[1:-1, 1:-1]) / h**2
print(np.abs(lap_5 - lap_exact[1:-1, 1:-1]).max()) # about 1.6e-3, error O(h^2)
# 3. a diffusion step with kappa*dt/h^2 = 1/4 is a four-neighbour average
rng = np.random.default_rng(0)
u = rng.random((64, 64))
print("std before:", u.std().round(3))
for _ in range(20):
up = np.pad(u, 1, mode="edge")
u = 0.25 * (up[1:-1, 2:] + up[1:-1, :-2] + up[2:, 1:-1] + up[:-2, 1:-1])
print("std after 20 steps:", u.std().round(3)) # 0.288 -> 0.037
# 4. 2D Poisson reconstruction: recover a disc from a noisy "normal field"
n = 128
h = 2.0 / (n - 1)
g = np.linspace(-1, 1, n)
X, Y = np.meshgrid(g, g)
r = np.hypot(X, Y)
chi0 = 0.5 * (1 - np.tanh((r - 0.5) / 0.05)) # smoothed indicator of a disc (ground truth)
gy, gx = np.gradient(chi0, h) # its gradient points inward near the boundary
Vx = gx + 0.2 * gx.std() * rng.standard_normal(gx.shape) # noisy observation
Vy = gy + 0.2 * gy.std() * rng.standard_normal(gy.shape)
divV = np.gradient(Vx, h, axis=1) + np.gradient(Vy, h, axis=0)
D = sp.diags([1.0, -2.0, 1.0], [-1, 0, 1], shape=(n, n)) / h**2
L = sp.kron(sp.identity(n), D) + sp.kron(D, sp.identity(n)) # five-point Laplacian, zero outside
chi = spla.spsolve(L.tocsc(), divV.ravel()).reshape(n, n)
inside0, inside = chi0 > 0.5, chi > 0.5
iou = (inside0 & inside).sum() / (inside0 | inside).sum()
print(np.abs(chi - chi0).max().round(3), iou.round(3)) # about 0.016, 0.999
References
- Kazhdan, M., Bolitho, M., & Hoppe, H. (2006). Poisson surface reconstruction. Proceedings of the Eurographics Symposium on Geometry Processing (SGP). https://hhoppe.com/proj/poissonrecon/
- Kazhdan, M., & Hoppe, H. (2013). Screened Poisson surface reconstruction. ACM Transactions on Graphics, 32(3), 29.
- Marr, D., & Hildreth, E. (1980). Theory of edge detection. Proceedings of the Royal Society of London. Series B, 207(1167), 187–217.
- Lowe, D. G. (2004). Distinctive image features from scale-invariant keypoints. International Journal of Computer Vision, 60(2), 91–110.
- Nocedal, J., & Wright, S. J. (2006). Numerical Optimization (2nd ed.), Chapter 10 (Least-Squares Problems). Springer.
- Evans, L. C. (2010). Partial Differential Equations (2nd ed.). American Mathematical Society.
- Khan Academy. The Hessian matrix and Intuition about the Laplacian (videos in the multivariable calculus course). https://www.khanacademy.org/math/multivariable-calculus
- Brunton, S. L. Div, Grad, and Curl: Vector Calculus Building Blocks for PDEs (YouTube). https://www.youtube.com/watch?v=lKXW7DRyyro