The Hessian: blobs, ridges and saddles

Image analysis

About this lecture

The LoG of the last unit adds up the curvature in two directions. Today we keep the two curvatures apart: the second-derivative test from calculus, applied at every pixel.

  • The Hessian: a symmetric 2 × 2 matrix of second derivatives per pixel, at scale σ.
  • Its eigenvalues are the curvatures along two perpendicular directions; its eigenvectors are those directions.
  • Classification: bright or dark blob, ridge (line), saddle, flat.
  • Trace (the LoG) and determinant.
  • Vesselness (Frangi): a score for line-like structures, over several scales.

Slides titled The math give the formulas and proofs; the ideas are complete without them.

The image as a landscape

Read the (smoothed) image as a height map: bright = high.

Four height maps with contour lines: hilltop −(x² + y²), ridge −x², saddle x² − y² and flat, each with axes along the two curvature directions, red for bending down and blue for bending up.
  • A bright spot is a hilltop: it bends down in every direction.
  • A bright line is a ridge: it bends down across the line, and not at all along it.
  • Two bright spots with two dark gaps between them make a pass (saddle): down one way, up the other.
  • A plain is flat. The question at each pixel: how does the surface bend, and in which directions?

The Hessian at every pixel

Three second derivatives of the Gaussian-smoothed image L at scale σ (separable kernels, as in the Canny unit):

H = \begin{pmatrix} L_{xx} & L_{xy} \\ L_{xy} & L_{yy} \end{pmatrix}

The three second-derivative-of-Gaussian kernels at σ = 2: Lxx (negative centre, positive sides along x), Lxy (four lobes in a checkerboard) and Lyy.
  • L_{xx}: curvature along x; L_{yy}: along y (down); L_{xy}: how the x-slope changes going down (the “twist”).
  • H is symmetric, so (recall the PCA unit) it has two real eigenvalues and two perpendicular eigenvectors.

Eigenvalues are curvatures

  • The curvature in a direction \mathbf u is a number that depends on \mathbf u. The eigenvectors of H are the directions of the largest and smallest curvature; the eigenvalues are those curvatures.
  • We order them by size: |\lambda_1| \le |\lambda_2|. So \lambda_2 is the strongest bending, \lambda_1 the weakest, in the perpendicular direction.
  • Negative eigenvalue: the brightness bends down (a bright structure). Positive: bends up (a dark structure).

Example: f = -x^2 (a bright ridge along y). H = \begin{pmatrix} -2 & 0 \\ 0 & 0 \end{pmatrix}: \lambda_1 = 0 with eigenvector (0, 1), along the ridge; \lambda_2 = -2 with eigenvector (1, 0), across it.

Curvature u·Hu plotted against the direction u from 0° to 180° for three surfaces. Hilltop −(x² + y²): −2 in every direction. Ridge −x²: from −2 along x to 0 along y. Saddle −x² + y²: from −2 along x to +2 along y. The smallest and largest values, at 0° and 90°, are the eigenvalues.

The math: curvature in a direction

Second-order Taylor expansion around a pixel \mathbf x:

L(\mathbf x + \mathbf h) \approx L(\mathbf x) + \nabla L^\top\mathbf h + \tfrac12\,\mathbf h^\top H\,\mathbf h.

  • Along a unit vector \mathbf u the second derivative (curvature of the profile) is \mathbf u^\top H\mathbf u.
  • Maximise or minimise \mathbf u^\top H\mathbf u subject to \mathbf u^\top\mathbf u = 1: Lagrange gives H\mathbf u = \lambda\mathbf u, and then \mathbf u^\top H\mathbf u = \lambda (a Rayleigh quotient, the same algebra as PCA).
  • So the extreme curvatures are the eigenvalues, along the eigenvectors. At a critical point (\nabla L = 0) this is the second-derivative test: both negative = maximum, both positive = minimum, opposite signs = saddle.

The math: eigenvalues in closed form

For a symmetric \begin{pmatrix} a & b \\ b & c \end{pmatrix} (here a = L_{xx}, b = L_{xy}, c = L_{yy}):

\lambda_{\pm} = \frac{a + c}{2} \pm \sqrt{\Big(\frac{a - c}{2}\Big)^2 + b^2}, \qquad \theta = \tfrac12\operatorname{atan2}(2b,\; a - c)

where θ is the angle of the eigenvector of \lambda_+ (in image coordinates, y down).

  • Two numbers do not depend on how the image is rotated: the trace a + c = \lambda_+ + \lambda_- and the determinant ac - b^2 = \lambda_+\lambda_-.
  • Example: \begin{pmatrix} -8 & 4 \\ 4 & -8 \end{pmatrix}: \lambda = -8 \pm 4, i.e. -4 and -12; θ = ½·atan2(8, 0) = 45°: the eigenvector of -4 (the weak curvature) is (1, 1)/\sqrt2, along the diagonal.

Reading the two eigenvalues

The plane of the two eigenvalues, λ1 across and λ2 up, divided into regions: bright blob, bright ridge, saddle, flat, dark ridge, dark blob.
\lambda_1 (small) \lambda_2 (large) structure
≈ 0 strongly < 0 bright ridge (line); \lambda_1’s eigenvector points along it
< 0, similar size < 0 bright blob
opposite sign saddle
≈ 0 ≈ 0 flat

Dark structures: the same with the signs flipped. An edge gives a weak, mixed answer: a half-ridge on each side, nothing on the edge itself. The Hessian is not an edge detector.

Try it: the Hessian per pixel

Trace and determinant

Two numbers per pixel that do not depend on the orientation:

  • Trace \lambda_1 + \lambda_2 = L_{xx} + L_{yy}: the LoG of the last unit. A blob with λ = (−10, −10) and a ridge with λ = (0, −20) both have trace −20: the LoG cannot tell a blob from a line.
  • Determinant \lambda_1\lambda_2: 100 for the blob, 0 for the ridge. Large only when both curvatures are large: the “determinant of Hessian” blob detector.
  • Pointer: the integral-image day computes the determinant of Hessian with box filters for speed (as in the SURF keypoint detector, keypoints).
A Gaussian spot and a straight bright line. At σ = 3 (values × σ²) the eigenvalues are about (−30, −30) at the spot and (0, −43) on the line. The trace is strongly negative on both (−60 and −43); the determinant is 906 at the spot and 0 on the line.

Vesselness: a score for lines

Frangi et al. (1998): a number between 0 and 1 that is large on bright lines (vessels, filaments, membranes) and small elsewhere.

  • Reward: \lambda_2 strongly negative, i.e. a strong structure is present.
  • Penalise: |\lambda_1/\lambda_2| large, i.e. a blob, not a line.
  • Two knobs: β sets how strictly blobs are rejected; c sets what counts as “strong” (above the noise).
  • Example (β = 0.5, c = 15): a line with λ = (0, −20) scores 0.59; a blob with λ = (−10, −10) only 0.05.
  • Dark lines: flip the sign test.

Vesselness as a colour over the plane of the two eigenvalues, λ2 from −40 to 0 across and λ1 between −|λ2| and |λ2| up. It is high near λ1 = 0 with λ2 strongly negative, and low near the diagonal λ1 = λ2 and near the origin. Marked: line (0, −20) 0.59, blob (−10, −10) 0.05, and the example of the math slide 0.58.

The math: Frangi’s vesselness (2D)

With |\lambda_1| \le |\lambda_2| (for bright lines):

\mathcal V = \begin{cases} 0 & \lambda_2 > 0 \\[2pt] \exp\!\Big(-\dfrac{R_B^2}{2\beta^2}\Big)\Big(1 - \exp\!\Big(-\dfrac{S^2}{2c^2}\Big)\Big) & \text{otherwise} \end{cases} \qquad R_B = \frac{\lambda_1}{\lambda_2},\quad S = \sqrt{\lambda_1^2 + \lambda_2^2}.

  • R_B is 0 for a perfect line and 1 for a round blob; the first factor is the “blobness” penalty.
  • S (the Frobenius norm of H) is small in flat, noisy regions; the second factor is the “structureness” reward.
  • Example: H = \begin{pmatrix} -20 & 2 \\ 2 & -3 \end{pmatrix}: \lambda = -2.77, -20.23, R_B = 0.137, S = 20.42; \mathcal V = 0.963 \cdot 0.604 = 0.58.
  • In 3D (one line): a 3 × 3 Hessian with three eigenvalues; blob (all three large), tube (two large), sheet (one large).

Multi-scale: one σ is not enough

  • A line responds best when σ matches its width: a thin filament at small σ, a thick vessel at large σ.
  • Compute the Hessian at several σ, normalise by σ² (as in the scale-space unit, so the scales are comparable), take the maximum vesselness over σ.
  • The winning σ grows with the line width (for a line with a Gaussian profile of width s, \sigma^2\lambda_2 peaks at \sigma = \sqrt2\,s; exercise).
  • Failure: at junctions two lines cross, both curvatures are large, and the junction looks like a blob: vesselness fades exactly where branches meet.
A synthetic test scene with a spot, lines of different widths, a dark line and a junction; the Hessian class of each pixel at σ = 3; and the vesselness, bright on the thin line and fading at the junction.

Multi-scale vesselness as pseudocode

best(x, y) = 0 for every pixel
for each σ in σ1 … σn:
    L = I blurred with a Gaussian of width σ
    for every pixel (x, y):
        H = σ² · [[Lxx, Lxy], [Lxy, Lyy]]          # second differences of L
        λ1, λ2 = eigenvalues of H, |λ1| ≤ |λ2|     # closed form, 2 × 2
        best(x, y) = max(best(x, y), vesselness(λ1, λ2))
  • One blur per scale, then a few multiplications per pixel: no matrix library needed.
  • Keeping the σ that wins as well gives the “best σ” map: the width of each line.

Try it: vesselness over scales

Ridges in practice

  • Microscopy: membranes, filaments (microtubules, actin), neurites, vessels.
  • Medical images: blood vessels in retinal photographs and angiograms (Frangi’s original use).
  • Other: roads in aerial images, cracks, the ridges of fingerprints.
  • Vessel and neuron networks (skeletonising them, measuring branches, junctions) are the subject of the skeleton day (neurons and vessels); it builds on this unit.

Left: the electron micrograph of a cell with its nucleus. Right: multi-scale vesselness for dark lines: the nuclear envelope is a bright closed curve; membranes outside the nucleus and short texture lines inside it also respond.

The membranes of the micrograph as dark lines (σ = 1 to 4, c = 20): the nuclear envelope stands out, but the texture inside the nucleus also responds.

Summary

  • Hessian = the 2 × 2 matrix of second derivatives of the smoothed image, at every pixel.
  • Its eigenvalues are the extreme curvatures, its eigenvectors their (perpendicular) directions; order |\lambda_1| \le |\lambda_2|.
  • Both negative: bright blob; \lambda_2 \ll 0, \lambda_1 \approx 0: bright ridge (along \lambda_1’s eigenvector); opposite signs: saddle; both ≈ 0: flat. Edges: weak half-ridges.
  • Trace = LoG (blob or ridge, cannot tell); determinant: blobs only.
  • Vesselness: rewards strong \lambda_2, penalises blob-like |\lambda_1/\lambda_2|; take the maximum over σ (normalised by σ²).