Harris and Stephens improved upon Moravec's corner detector by considering the differential of the corner score with respect to direction directly, instead of using shifted patches. (This corner score is often referred to as
autocorrelation, since the term is used in the paper in which this detector is described. However, the mathematics in the paper clearly indicate that the sum of squared differences is used.)
Without loss of generality, we will assume a grayscale 2-dimensional image is used. Let this image be given by I. Consider taking an image patch over the area (u, v) and shifting it by (x, y). The weighted
sum of squared differences (SSD) between these two patches, denoted S, is given by S(x, y) = \sum_u \sum_v w(u, v) [I(u + x, v + y) - I(u, v)]^2. I(u + x, v + y) can be approximated by a
Taylor expansion. Let I_x and I_y be the partial
derivatives of I, such that I(u + x, v + y) \approx I(u, v) + I_x(u, v) x + I_y(u, v) y. This produces the approximation S(x, y) \approx \sum_u \sum_v w(u, v) [I_x(u, v) x + I_y(u, v) y]^2, which can be written in matrix form: S(x, y) \approx \begin{bmatrix} x & y \end{bmatrix} A \begin{bmatrix} x \\ y \end{bmatrix}, where
A is the
structure tensor, A = \sum_u \sum_v w(u, v) \begin{bmatrix} I_x(u, v)^2 & I_x(u, v) I_y(u, v) \\ I_x(u, v) I_y(u,v) & I_y(u, v)^2 \end{bmatrix} = \begin{bmatrix} \langle I_x^2 \rangle & \langle I_x I_y \rangle \\ \langle I_x I_y \rangle & \langle I_y^2 \rangle \end{bmatrix}. In words, we find the
covariance of the
partial derivative of the image intensity I with respect to the x and y axes. Angle brackets denote averaging (i.e. summation over (u, v)), and w(u, v) denotes the type of window that slides over the image. If a
box filter is used, the response will be
anisotropic, but if a
Gaussian is used, then the response will be
isotropic. A corner (or in general an interest point) is characterized by a large variation of S in all directions of the vector \begin{bmatrix} x & y \end{bmatrix}. By analyzing the eigenvalues of A, this characterization can be expressed in the following way: A should have two "large" eigenvalues for an interest point. Based on the magnitudes of the eigenvalues, the following inferences can be made based on this argument: • If \lambda_1 \approx 0 and \lambda_2 \approx 0, then this pixel (x, y) has no features of interest. • If \lambda_1 \approx 0 and \lambda_2 has some large positive value, then an edge is found. • If \lambda_1 and \lambda_2 have large positive values, then a corner is found. Harris and Stephens note that exact computation of the eigenvalues is computationally expensive, since it requires the computation of a
square root, and instead suggest the function M_c = \lambda_1 \lambda_2 - \kappa (\lambda_1 + \lambda_2)^2 = \det(A) - \kappa \operatorname{tr}^2(A), where \kappa is a tunable sensitivity parameter. Therefore, the algorithm does not have to actually compute the
eigenvalue decomposition of the matrix A, and instead it is sufficient to evaluate the
determinant and
trace of A to find corners, or rather interest points in general. The Shi–Tomasi corner detector directly computes \min(\lambda_1, \lambda_2) because under certain assumptions, the corners are more stable for tracking. Note that this method is also sometimes referred to as the Kanade–Tomasi corner detector. The value of \kappa has to be determined empirically, and in the literature values in the range 0.04–0.15 have been reported as feasible. One can avoid setting the parameter \kappa by using Noble's corner measure M_c' which amounts to the
harmonic mean of the eigenvalues: M_c' = 2 \frac{\det(A)}{\operatorname{tr}(A) + \epsilon}, where \epsilon is a small positive constant. If A can be interpreted as the
precision matrix for the corner position, the
covariance matrix for the corner position is A^{-1}, i.e. \frac{1}{\langle I_x^2 \rangle \langle I_y^2 \rangle - \langle I_x I_y \rangle^2} \begin{bmatrix} \langle I_y^2 \rangle & -\langle I_x I_y \rangle \\ -\langle I_x I_y \rangle & \langle I_x^2 \rangle \end{bmatrix}. The sum of the eigenvalues of A^{-1}, which in that case can be interpreted as a
generalized variance (or a "total uncertainty") of the corner position, is related to Noble's corner measure M_c' as \lambda_1(A^{-1}) + \lambda_2(A^{-1}) = \frac{\operatorname{tr}(A)}{\det(A)} \approx \frac{2}{M_c'}. == The Förstner corner detector ==