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 a translation (x,y)(x,y):

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

where:

In each pixel (m,n)(m,n), the minimum of Em,n(y,x)E_{m,n}(y,x) 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 only the initial four directions), a Taylor series expansion is performed on the shifted sub-image f(u+y,v+x)f(u+y,v+x):

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

so :

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

This expression can be written in the following matrix form:

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

where

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

If a corner is present at pixel (m,n)(m,n), then the derivatives of ff are very large, so MM has large coefficients, so the eigenvalues λ1\lambda_1 and λ2\lambda_2 of MM are also very large. Because the calculation of the eigenvalues can be cumbersome, it is attractive to use other quantities related to the eigenvalues. Harris propose to use the trace tr(M)=λ1+λ2\mathrm{tr}(M)=\lambda_1 + \lambda_2 and determinant det(M)=λ1λ2\mathrm{det}(M)=\lambda_1 \lambda_2 of the matrix MM. These values can be calculated easily:

tr(M)=M1,1+M2,2anddet(M)=M1,1M2,2−M1,2M2,1.\mathrm{tr}(M) = M_{1,1} + M_{2,2} \quad\text{and}\quad \mathrm{det}(M) = M_{1,1}M_{2,2} - M_{1,2}M_{2,1}.

Finally, Harris propose to calculate

R=det(M)−k(tr(M))2R = \mathrm{det}(M) - k (\mathrm{tr}(M))^2

with 0.04<k<0.060.04 < k < 0.06. The values of RR are low in a flat regions, negative on edges, and positive on corners. An example is given Figure 2.

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

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