# Harris corner detector

The Harris corner detector is a classic computer vision algorithm for identifying corners and interest points in images, introduced by Chris Harris and Mike Stephens in 1988, widely used in feature matching and tracking.

The Harris corner detector is a foundational algorithm in computer vision for identifying corner points in an image. It was introduced by Chris Harris and Mike Stephens in 1988 in a paper titled "A Combined Corner and Edge Detector." The detector is designed to locate points where the image intensity has large variations in multiple directions, which are useful for tasks such as feature matching, object recognition, and motion tracking. It is a cornerstone technique in the field, predating many modern [machine-learning](https://www.wikiprompt.org/wiki/machine-learning) approaches but still widely used in classical pipelines and as a baseline for learned feature detectors.

The algorithm operates on grayscale images and computes a response measure based on the local gradient structure. For each pixel, it constructs a second-moment matrix (also called the structure tensor) that summarizes the distribution of image gradients in a small neighborhood. The eigenvalues of this matrix indicate the strength of intensity changes along two orthogonal directions. A corner is detected when both eigenvalues are large, meaning the image patch has significant variation in all directions. The response function, often denoted as R, combines the determinant and trace of the matrix to avoid explicit eigenvalue computation, using a tunable parameter k (typically around 0.04 to 0.06).

## Mathematical Formulation

The Harris detector defines the second-moment matrix M for a pixel (x, y) as a sum over a window W, typically a Gaussian-weighted neighborhood:

M = sum over W of [Ix^2, IxIy; IxIy, Iy^2]

where Ix and Iy are the image gradients in the x and y directions, computed using Sobel or similar operators. The response R is given by:

R = det(M) - k * trace(M)^2

where det(M) = λ1 * λ2 and trace(M) = λ1 + λ2, with λ1 and λ2 being the eigenvalues. A pixel is classified as a corner if R exceeds a threshold, and non-maximum suppression is applied to retain only local maxima, producing a sparse set of interest points.

## Properties and Advantages

The Harris corner detector is invariant to image rotation, meaning that a corner detected in one orientation will be detected after rotating the image. It is also partially invariant to illumination changes because it relies on gradient magnitudes rather than absolute intensities. However, it is not scale-invariant; a corner may disappear or change when the image is scaled, which led to later developments like the scale-invariant feature transform (SIFT) and other multi-scale detectors. The detector is computationally efficient, making it suitable for real-time applications, especially in the era before deep learning.

## Applications in Computer Vision

Harris corners are used in many classical computer vision tasks. In [data-augmentation](https://www.wikiprompt.org/wiki/data-augmentation) and image stitching, they serve as keypoints for matching between overlapping images. In motion tracking, they provide stable points to follow across video frames. The detector is also a building block for more complex feature descriptors, such as the Harris-Laplace detector, which adds scale selection. In robotics and autonomous driving, Harris corners help in visual odometry and simultaneous localization and mapping (SLAM), though modern systems often use learned features from [neural-network](https://www.wikiprompt.org/wiki/neural-network) models.

## Relation to Modern Approaches

With the rise of [deep-learning](https://www.wikiprompt.org/wiki/deep-learning) and [convolutional-neural-network](https://www.wikiprompt.org/wiki/convolutional-neural-network)-based methods, the Harris corner detector has been largely superseded by learned interest point detectors that can adapt to specific tasks and data. However, it remains an important educational tool and a baseline for evaluating new algorithms. Many libraries, such as OpenCV, provide built-in implementations, and it is still used in scenarios where computational resources are limited or where interpretability is desired. The principles of gradient-based corner detection also influence modern feature extraction layers in [residual-network](https://www.wikiprompt.org/wiki/residual-network) and other architectures.

## Limitations and Extensions

A key limitation is the lack of scale invariance, which the Harris-Laplace and Hessian-Laplace detectors address by incorporating scale-space analysis. The detector is also sensitive to noise, though Gaussian smoothing mitigates this. Extensions like the Shi-Tomasi corner detector, which uses the minimum eigenvalue as the response, improve robustness for tracking applications. In practice, the Harris detector is often combined with non-maximum suppression and subpixel refinement to achieve accurate keypoint localization.

## Historical Context

The Harris corner detector emerged from work at the [xerox-parc](https://www.wikiprompt.org/wiki/xerox-parc) and other research labs in the 1980s, building on earlier corner detection methods by Moravec. It was a significant advance because it provided a more stable and repeatable response than previous techniques. The algorithm's simplicity and effectiveness made it a standard tool in computer vision curricula and industrial applications. Even as [artificial-intelligence](https://www.wikiprompt.org/wiki/artificial-intelligence) and [generative-ai](https://www.wikiprompt.org/wiki/generative-ai) have transformed the field, the Harris corner detector remains a testament to the enduring value of classical geometric and statistical methods.

## Implementation Notes

In practice, the detector requires selecting the window size, the Gaussian sigma, and the threshold for R. Common choices include a 3x3 or 5x5 window, sigma around 1, and a threshold based on a fraction of the maximum response. The algorithm is implemented in popular libraries like OpenCV, scikit-image, and MATLAB, making it accessible for prototyping. For large images, the computation can be vectorized using convolution operations, which is efficient on modern hardware.

## See Also

- [machine-learning](https://www.wikiprompt.org/wiki/machine-learning)
- [neural-network](https://www.wikiprompt.org/wiki/neural-network)
- [data-augmentation](https://www.wikiprompt.org/wiki/data-augmentation)
- [residual-network](https://www.wikiprompt.org/wiki/residual-network)

---
Source: https://www.wikiprompt.org/wiki/harris-corner-detector
License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
Last updated: 2026-09-14T06:29:47.5437+00:00
