Quiz: the structure tensor

Short questions to test your understanding. Try each on paper first, then open the answer. Eigenvalues of J: \mu_1 \ge \mu_2 \ge 0.


Q1. Why does averaging the gradient vectors in a window fail to find the orientation of a bright line?

Which way do the gradients point on the two sides of the line?

On both sides the gradient points towards the line (towards the brighter middle): on one side in direction \mathbf g, on the other in -\mathbf g. They cancel, and the average is about zero although the orientation is perfectly clear. The outer product \mathbf g\mathbf g^\top is the same for \mathbf g and -\mathbf g, so averaging it does not cancel.


Q2. The structure tensor has two scales, σ and ρ. What does each control?

One is applied before the products, one after.

σ is the scale of the gradient (the derivative of a Gaussian): it controls noise and which structures produce gradients at all. ρ is the width of the Gaussian window that averages the products: it controls how large a region is summarised by one tensor. Too small a ρ gives noisy orientations; too large a ρ blurs boundaries between differently oriented regions.


Q3. Classify the window: (a) \mu_1 = 900, \mu_2 = 5; (b) \mu_1 = 600, \mu_2 = 450; (c) \mu_1 = 2, \mu_2 = 1 (noise gives up to about 10).

How many large eigenvalues?

  1. An edge or oriented texture (one large eigenvalue, coherence (895/905)^2 = 0.98). (b) A corner (or an isotropic, busy texture): two large eigenvalues, coherence (150/1050)^2 = 0.02. (c) Flat: both within the noise.

Q4. The structure tensor is “the covariance matrix of the gradients”. Describe the gradient point cloud of an edge, a corner and a flat region.

Plot every gradient in the window as a point (L_x, L_y).

Edge: the points lie along a line through the origin (all gradients parallel or antiparallel): a long thin ellipse. Corner: points along two different directions: a broad, roundish ellipse. Flat: all points near the origin: a tiny ellipse. The eigenvalues of J are the squared half-axes of the ellipse (up to a factor).


Q5. What is the Harris response \det J - k(\operatorname{tr}J)^2 (with k = 0.05) for J = \begin{pmatrix} 8 & 0 \\ 0 & 8\end{pmatrix} and for J = \begin{pmatrix} 16 & 0 \\ 0 & 0\end{pmatrix}? Which is the corner?

Both have the same trace.

First: 64 - 0.05 \cdot 256 = 51.2, a corner. Second: 0 - 0.05 \cdot 256 = -12.8, an edge (negative). Same trace (total gradient energy), but only the first has it in two directions.


Q6. Why are there no corners at all if the window is switched off (ρ = 0)?

What is the rank of \mathbf g\mathbf g^\top?

Without averaging, J = \nabla L\,\nabla L^\top at each pixel has rank 1: \mu_2 = 0 and \det J = 0. A single gradient has a single direction; two directions can only come from different pixels in a window. Every pixel looks like an edge, and the Harris response is never positive.


Q7. Hessian or structure tensor? (a) Find the centre line of a blood vessel. (b) Measure the dominant fibre direction in a patch of collagen. (c) Find points to track between two video frames.

Second derivatives, signed, at centres; or squared first derivatives, unsigned, in windows?

  1. Hessian: the vessel’s centre is where the curvature across it is strongest (the gradient is zero there). (b) Structure tensor: orientation and coherence of a texture in a window. (c) Structure tensor: corners (Harris or \mu_2), which can be found again after a shift.

Q8. (math) Show that \mathbf u^\top J\mathbf u is the average of (\nabla L\cdot\mathbf u)^2 over the window, and explain why its maximum over unit vectors is \mu_1.

(\mathbf g\cdot\mathbf u)^2 = \mathbf u^\top\mathbf g\mathbf g^\top\mathbf u; then the Rayleigh quotient.

(\mathbf g\cdot\mathbf u)^2 = (\mathbf u^\top\mathbf g)(\mathbf g^\top\mathbf u) = \mathbf u^\top(\mathbf g\mathbf g^\top)\mathbf u; averaging is linear, so \langle(\nabla L\cdot\mathbf u)^2\rangle = \mathbf u^\top\langle\nabla L\nabla L^\top\rangle\mathbf u = \mathbf u^\top J\mathbf u. Writing \mathbf u = \cos\phi\,\mathbf e_1 + \sin\phi\,\mathbf e_2 in the orthonormal eigenvectors of J: \mathbf u^\top J\mathbf u = \mu_1\cos^2\phi + \mu_2\sin^2\phi \le \mu_1, with equality along \mathbf e_1.