# Harris Corner Detector

Harris Corner Detector is a corner detection operator that is commonly used in computer vision algorithms to extract corners and infer features of an image. It was first introduced by Chris Harris and Mike Stephens in 1988 upon the improvement of Moravec's corner detector. Compared to the previous one, Harris' corner detector takes the differential of the corner score into account with reference to direction directly, instead of using shifting patches for every 45 degree angles, and has been proved to be more accurate in distinguishing between edges and corners. Since then, it has been improved and adopted in many algorithms to preprocess images for subsequent applications.

## Introduction

A corner is a point whose local neighborhood stands in two dominant and different edge directions. In other words, a corner can be interpreted as the junction of two edges, where an edge is a sudden change in image brightness. Corners are the important features in the image, and they are generally termed as interest points which are invariant to translation, rotation and illumination. Although corners are only a small percentage of the image, they contain the most important features in restoring image information, and they can be used to minimize the amount of processed data for motion tracking, image stitching, building 2D mosaics, stereo vision, image representation and other related computer vision areas.

In order to capture the corners from the image, researchers have proposed many different corner detectors including the Kanade-Lucas-Tomasi (KLT) operator and the Harris operator which are most simple, efficient and reliable for use in corner detection. These two popular methodologies are both closely associated with and based on the local structure matrix. Compared to the Kanade-Lucas-Tomasi corner detector, the Harris corner detector provides good repeatability under changing illumination and rotation, and therefore, it is more often used in stereo matching and image database retrieval. Although there still exists drawbacks and limitations, the Harris corner detector is still an important and fundamental technique for many computer vision applications.

## Development of Harris Corner Detection Algorithm 

Without loss of generality, we will assume a grayscale 2-dimensional image is used. Let this image be given by $I$ . Consider taking an image patch $(x,y)\in W$ (window) and shifting it by $(\Delta x,\Delta y)$ . The sum of squared differences (SSD) between these two patches, denoted $f$ , is given by:

$f(\Delta x,\Delta y)={\underset {(x_{k},y_{k})\in W}{\sum }}\left(I(x_{k},y_{k})-I(x_{k}+\Delta x,y_{k}+\Delta y)\right)^{2}$ $I(x+\Delta x,y+\Delta y)$ can be approximated by a Taylor expansion. Let $I_{x}$ and $I_{y}$ be the partial derivatives of $I$ , such that

$I(x+\Delta x,y+\Delta y)\approx I(x,y)+I_{x}(x,y)\Delta x+I_{y}(x,y)\Delta y$ This produces the approximation

$f(\Delta x,\Delta y)\approx {\underset {(x,y)\in W}{\sum }}\left(I_{x}(x,y)\Delta x+I_{y}(x,y)\Delta y\right)^{2},$ which can be written in matrix form:

$f(\Delta x,\Delta y)\approx {\begin{pmatrix}\Delta x&\Delta y\end{pmatrix}}M{\begin{pmatrix}\Delta x\\\Delta y\end{pmatrix}},$ where M is the structure tensor,

$M={\underset {(x,y)\in W}{\sum }}{\begin{bmatrix}I_{x}^{2}&I_{x}I_{y}\\I_{x}I_{y}&I_{y}^{2}\end{bmatrix}}={\begin{bmatrix}{\underset {(x,y)\in W}{\sum }}I_{x}^{2}&{\underset {(x,y)\in W}{\sum }}I_{x}I_{y}\\{\underset {(x,y)\in W}{\sum }}I_{x}I_{y}&{\underset {(x,y)\in W}{\sum }}I_{y}^{2}\end{bmatrix}}$ ## Process of Harris Corner Detection Algorithm

Commonly, Harris corner detector algorithm can be divided into five steps.

1. Color to grayscale

2. Spatial derivative calculation

3. Structure tensor setup

4. Harris response calculation

5. Non-maximum suppression

### Color to grayscale

If we use Harris corner detector in a color image, the first step is to convert it into a grayscale image, which will enhance the processing speed.

### Spatial derivative calculation

Next, we are going to compute $I_{x}(x,y),I_{y}(x,y)$ .

### Structure tensor setup

With $I_{x}(x,y)$ , $I_{y}(x,y)$ , we can construct the structure tensor $M$ .

### Harris response calculation

In this step, we will compute the smallest eigenvalue of the structure tensor with following approximation equation.

$\lambda _{min}\approx {\frac {\lambda _{1}\lambda _{2}}{(\lambda _{1}+\lambda _{2})}}={\frac {det(M)}{trace(M)}}$ where $trace(M)=m_{11}+m_{22}$ .

Another commonly used Harris response calculation is shown as below,

$R=det(M)-k(trace(M))^{2}=\lambda _{1}\lambda _{2}-k(\lambda _{1}+\lambda _{2})^{2}$ where $k$ is an empirically determined constant; $k\in [0.04,0.06]$ .

### Non-maximum suppression

In order to pick up the optimal values to indicate corners, we find the local maxima as corners within the window which is a 3 by 3 filter.

## Improvement

1. Harris-Laplace Corner Detector

2. Differential Morphological Decomposition Based Corner Detector

3. Multi-scale Bilateral Structure Tensor Based Corner Detector

## Applications

1. Image Alignment, Stitching and Registration

2. 2D Mosaics Creation

3. 3D Scene Modeling and Reconstruction

4. Motion Detection

5. Object Recognition

6. Image Indexing and Content-based Retrieval

7. Video Tracking