Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

To detect the corners of objects in an image, one can start by detecting edges then determining where two edges meet. There are however other methods, among which:

Moravec detector

The principle of this detector is to observe if a sub-image, moved around one pixel in all directions, changes significantly. If this is the case, then the considered pixel is a corner.

Principle of Moravec detector.
From left to right :
on a flat area, small shifts in the sub-image (in red) do not cause any change;
on a contour, we observe changes in only one direction;
around a corner there are significant changes in all directions.

Figure 1:Principle of Moravec detector. From left to right : on a flat area, small shifts in the sub-image (in red) do not cause any change; on a contour, we observe changes in only one direction; around a corner there are significant changes in all directions.

Mathematically, the change is characterized in each pixel (m,n)(m,n) of the image by Em,n(x,y)E_{m,n}(x,y) which represents the difference between the sub-images for an offset (x,y)(x,y):

∀m,n,x,yEm,n(x,y)=∑u,vwm,n(u,v)[f(u+x,v+y)−f(u,v)]2\forall m,n,x,y \qquad E_{m,n}(x,y) = \sum_{u,v} w_{m,n}(u,v) \big[f(u+x,v+y)-f(u,v)\big]^2

where:

In each pixel (m,n)(m,n), the minimum of Em,n(x,y)E_{m,n}(x,y) in the four directions is kept and denoted Fm,nF_{m,n}. Finally, the detected corners correspond to the local maxima of Fm,nF_{m,n}, that is, at pixels (m,n)(m,n) where the smallest value of Em,n(x,y)E_{m,n}(x,y) is large.

It turns out that Moravec detector has several limitations. First, ww is a binary window and therefore the detector considers all pixels in the window with the same weight. When the noise in the image is high, it can lead to false corner detections. Second, only four directions are considered. Third, the detector remains very sensitive to edges because only the minimum of EE is considered. For these reasons, Harris has proposed a detector to overcome these limitations.

Harris detector

To avoid a noisy response, the rectangular window ww of the Moravec detector is replaced by a Gaussian window ww in the expression of Em,n(x,y)E_{m,n}(x,y).

To extend the Moravec detector to all directions, not limited to the initial four directions, a Taylor series expansion is performed on the shifted sub-image f(u+x,v+y)f(u+x,v+y):

f(u+x,v+y)≈f(u,v)+x ∂xf(u,v)+y ∂yf(u,v).f(u+x,v+y) \approx f(u,v) + x \,\partial_x f(u,v) + y \,\partial_y f(u,v).

Therefore :

Em,n(x,y)≈∑u,vwm,n(u,v)[x ∂xf(u,v)+y ∂yf(u,v)]2E_{m,n}(x,y) \approx \sum_{u,v} w_{m,n}(u,v) \big[ x \,\partial_x f(u,v) + y \,\partial_y f(u,v) \big]^2

This expression can be written in the following matrix form:

Em,n(x,y)≈(xy)M(xy)E_{m,n}(x,y) \approx \begin{pmatrix} x & y \end{pmatrix} M \begin{pmatrix} x \\ y \end{pmatrix}

where

M=∑u,vwm,n(u,v)((∂xf)2∂xf ∂yf∂xf ∂yf(∂yf)2)M = \sum_{u,v} w_{m,n}(u,v) \begin{pmatrix} (\partial_x f)^2 & \partial_x f \,\partial_y f \\ \partial_x f \,\partial_y f & (\partial_y f)^2 \\ \end{pmatrix}

Finally, the last limit of the Moravec detector can be avoided by considering a new measure of the presence of a corner: more information about the intensity change in the window can be obtained by analyzing the eigenvalues λ1\lambda_1 and λ2\lambda_2 of the matrix MM (Figure 2). Indeed, the presence of a corner is attested if the derivatives of ff are very large, then MM has large coefficients, and its eigenvalues are also very large.

Decision to be taken in function of the eigenvalues.

Figure 2:Decision to be taken in function of the eigenvalues.

The calculation of the eigenvalues of MM can be difficult, so an alternative is to calculate:

R=det(M)−k(trace(M))2=λ1λ2−k(λ1+λ2)2R = \mathrm{det}(M) - k (\mathrm{trace}(M))^2 = \lambda_1 \lambda_2 - k(\lambda_1 + \lambda_2)^2

with 0.04<k<0.060.04 < k < 0.06.

Thus, the values of RR are low in a flat region, negative on an edge, and positive on a corner (Figure 3).

Decision to be taken in function of R.

Figure 3:Decision to be taken in function of RR.

The Harris detector is illustrated on the example of Figure 4.

Harris detector.
The binary images represent the negative (contours), weak (flat areas) and positive (corners) values of the coefficient R.

Figure 4:Harris detector. The binary images represent the negative (contours), weak (flat areas) and positive (corners) values of the coefficient RR.