Notes

Corner Detection (Harris)

A corner is a small image region whose appearance changes noticeably when viewed from almost any nearby direction. Think of the junction of two window-frame edges: shifting a tiny patch left, right, up, or down produces a different pattern. Harris corner detection finds these distinctive points so a computer can recognize, match, or track parts of a scene.

How Harris detects a corner
The method examines image brightness changes inside a small window around every pixel. It first calculates image gradients: how strongly brightness changes horizontally and vertically. From these gradients, it builds a small 2×2 structure tensor (also called the second-moment matrix), which describes variation in the patch.

  • For a flat area, brightness changes little in every direction.
  • For an edge, brightness changes strongly across the edge but barely along it.
  • For a corner, brightness changes strongly in both directions.
Harris converts this information into a response score: R = det(M) − k·trace(M)², where M is the structure tensor and k is a small tuning constant. Large positive scores indicate candidate corners.

From response map to useful keypoints
A raw response map contains clusters of high scores around the same physical corner. The detector applies a threshold and non-maximum suppression, retaining only the strongest point in each neighborhood. Before gradients are measured, the image is usually smoothed with a Gaussian filter to reduce noise. The resulting keypoints are locations, not full descriptions of what surrounds them; systems commonly pair them with a descriptor for matching.

Why it matters in practice
Harris corners provide stable landmarks for tasks such as tracking a vehicle across video frames, stitching overlapping photos into a panorama, or aligning inspection images of a manufactured part. A plain wall offers little to match; screw heads, label corners, and panel junctions offer strong Harris responses. The method is fairly robust to moderate lighting changes and small shifts, but the original version is not inherently scale-invariant or rotation-invariant. In OpenCV, cv.cornerHarris() computes its response map; later methods such as SIFT and ORB add stronger matching and scale-handling capabilities.

Harris corner detection is a classical feature detector that identifies image locations where intensity changes strongly in two directions, such as corners and textured junctions. It scores local gradient variation using the structure tensor, producing stable keypoints under small translations and rotations. These points support image matching, tracking, registration, and panorama stitching; without reliable corners, correspondence between images becomes less accurate.

Imagine trying to match two photos of the same building. Smooth walls all look alike, but a window corner, roof edge, or street-sign intersection is easy to recognize. Harris corner detection is a classic computer-vision method for finding these especially distinctive spots in an image.

It looks for places where the picture changes strongly in more than one direction—what we naturally see as a corner or junction. These points act like visual landmarks. They help a system line up photos, stitch a panorama together, track an object in video, or estimate how a camera moved. Rather than trying to understand the whole scene at once, it gives the computer reliable little “anchors” to compare.