
Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 18, 2024
In this tutorial, we’ll talk about Harris Corner Detection, a mathematical approach to detecting corners in an image. First, we’ll illustrate the mathematical formulation. Then, we’ll show the step-by-step procedure to perform the Harris Corner Detector.
A corner is a point whose local neighborhood is characterized by large intensity variation in all directions. Corners are important features in computer vision because they are points stable over changes of viewpoint and illumination. The so-called Harris Corner Detector was introduced by Chris Harris and Mike Stephens in 1988 in the paper “A Combined Corner and Edge Detector”.
Let’s consider a two-dimensional image and a patch
of size
centered in
. We want to evaluate the intensity variation occurred if the window
is shifted by a small amount
. Such variation can be estimated by computing the Sum of Squared Differences (SSD):
(1)
where is a window function that can be a rectangular or a Gaussian function. We need to maximize the function
for corner detection. Since
and
are small, the shifted intensity
can be approximated by the following first-order Taylor expansion:
(2)
where and
are partial derivatives of
in
and
direction, respectively. By substituting (2) in (1) we obtain:
(3)
The equation (3) can be expressed in the following matrix form:
(4)
where is a
matrix computed from image derivatives:
(5)
The matrix is called structure tensor.
The Harris detector uses the following response function that scores the presence of a corner within the patch:
(6)
is a constant to chose in the range
. Since
is a symmetric matrix,
and
where
and
are the eigenvalues of
. Hence, we can express the corner response as a function of the eigenvalues of the structure tensor:
(7)
So the eigenvalues determine whether a region is an edge, a corner or flat:
The classification of the points using the eigenvalues of the structure tensor is represented in the following figure:
Harris corner detector consists of the following steps.
(8)
(9)
(10)
In the following figure we show a real application of the Harris Corner Detector. The corner response map (top-right image) was computed using Eq. 10 with k=0.04. The bottom-left image represents the thresholded corner response obtained with . The detected corners obtained after the application of the non-max suppression are shown in the bottom-right image.
In this article, we reviewed the Harris Corner Detector, a fundamental technique in computer vision. We explained the mathematical formulation, and finally, we explained how to implement it.