Autocorrelation surface

Look at an image through a small window and shift it a little. In a flat region nothing changes, on an edge only shifts across the edge change something, and at a corner every shift does. Pick a pixel and see how the change E(u,v)E(u, v) depends on the shift, and how well the second moment matrix MM predicts it.

Image II click to select the window center
Neighborhood window shifted by (u, v)
E(u,v)E(u, v) black = 0, click to select a shift
Approximation [u   v] M [u   v]⊤[u \;\, v] \, M \, [u \;\, v]^\top ellipse at half the white level
Sections through (0,0)(0, 0) E(u,0)E(u, 0) M11u2M_{11} u^2 E(0,v)E(0, v) M22v2M_{22} v^2

Interest points

Many tasks need points that can be found again in another image of the same scene: aligning images for a panorama, 3D reconstruction from many photos, tracking motion, image retrieval and object recognition. They all follow three steps: detect distinctive points, describe the neighborhood of each one as a vector, and match the descriptors between images. Good interest points are

The detector runs on each image independently, without knowing where the point will end up in the other image. What it can check is how stable a location is: how much its neighborhood changes when it is shifted slightly.

Change of appearance under a shift

The change of the window ww for a shift (u,v)(u, v) is the weighted sum of squared differences

E(u,v)=∑x,yw(x,y)[I(x+u,y+v)−I(x,y)]2E(u, v) = \sum_{x, y} w(x, y) \left[ I(x + u, y + v) - I(x, y) \right]^2

The window function ww is 1 inside the window and 0 outside (box), or a Gaussian that weights the center more. Here its weights sum to 1, so the values don't depend on the window size. Small values mean that the shifted window looks like the original one (high correlation, black), large values that it looks different (white). The shape of EE tells the three cases apart:

A corner is a distinct minimum of EE. Computing EE directly is slow, though: it costs the window size times the number of shifts for every pixel of the image.

Quadratic approximation

For small shifts, a second-order Taylor expansion of EE around (0,0)(0, 0) describes its shape:

E(u,v)≈E(0,0)+[uv][Eu(0,0)Ev(0,0)]+12[uv][Euu(0,0)Euv(0,0)Euv(0,0)Evv(0,0)][uv]E(u, v) \approx E(0, 0) + \begin{bmatrix} u & v \end{bmatrix} \begin{bmatrix} E_u(0, 0) \\ E_v(0, 0) \end{bmatrix} + \frac{1}{2} \begin{bmatrix} u & v \end{bmatrix} \begin{bmatrix} E_{uu}(0, 0) & E_{uv}(0, 0) \\ E_{uv}(0, 0) & E_{vv}(0, 0) \end{bmatrix} \begin{bmatrix} u \\ v \end{bmatrix}

E(0,0)=0E(0, 0) = 0 and, since this is a minimum, the first derivatives vanish as well. Only the quadratic term remains. The same result follows from the first-order expansion of the image, I(x+u,y+v)≈I(x,y)+Ixu+IyvI(x + u, y + v) \approx I(x, y) + I_x u + I_y v:

E(u,v)≈∑x,yw(x,y)[Ixu+Iyv]2=[uv]M[uv],M=∑x,yw(x,y)[Ix2IxIyIxIyIy2]E(u, v) \approx \sum_{x, y} w(x, y) \left[ I_x u + I_y v \right]^2 = \begin{bmatrix} u & v \end{bmatrix} M \begin{bmatrix} u \\ v \end{bmatrix}, \qquad M = \sum_{x, y} w(x, y) \begin{bmatrix} I_x^2 & I_x I_y \\ I_x I_y & I_y^2 \end{bmatrix}

The second moment matrix MM only needs the image derivatives, here central differences, and no shifted copies of the window. Compare the two maps: near the center they agree, further out EE levels off while the parabola keeps growing, because the derivatives only describe the image close to the pixel.

Eigenvalues and the ellipse

The lines of constant [u   v] M [u   v]⊤[u \;\, v] \, M \, [u \;\, v]^\top are ellipses. Their axes point along the eigenvectors of MM, and their lengths are proportional to λ−1/2\lambda^{-1/2}: the short axis (λmax)−1/2(\lambda_\text{max})^{-1/2} points in the direction of the fastest change, the long axis (λmin)−1/2(\lambda_\text{min})^{-1/2} in the direction of the slowest change. The eigenvalues therefore classify the window:

How large is large depends on the contrast of the image. The Harris detector avoids choosing two eigenvalue thresholds and combines both into a single cornerness score.

Try this