Anda di halaman 1dari 9

Feature Detection - Harris Corner Detector

Pi19404
February 23, 2013

Contents

Contents
Feature Detection - Harris Corner Detector 3

0.1 Introduction . . . . . . . . . 0.2 Feature Detection . . . . 0.3 Morvec Corner Detector 0.4 Corner Filtering . . . . . . 0.5 Implementation . . . . . . . . 0.6 Code . . . . . . . . . . . . . . References . . . . . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

3 3 3 7 7 8 9

2 | 9

Feature Detection - Harris Corner Detector

Feature Detection - Harris Corner Detector


0.1 Introduction
In this article we will look at the implementation of of a feature detection technique called Harris Corner Detector by Chris Harris and Mike Stephens

0.2 Feature Detection


The aim of feature detection is to identify point in the image that correpond to object in motion that can be tracked in adjacent image frames reliably. It is also required the feature be as sparse as possible to reduce the computational requirement and enable us to achieve real time tracking. Potential candidates for good feature are edge pixels. A subset of edge pixels are choosen as feature as seen in good feature to track feature detector where the edges were filtered based on criteria that minimum eigen value is greater than a specific threshold. Thus in generic terms first stage of feature detection corresponds to edge filtering. The edge maps consits of connected of linked edges and juntion or corners where edge orientation changes by large ammount.

0.3 Morvec Corner Detector


Moravecs corner detector functions by considering a local window in the image.

3 | 9

Feature Detection - Harris Corner Detector Now the window is shifted by small ammount and average change in intensity are analysed by shifting the window by small ammount in different directions. If the windowed patch has approximately constant intensity then all shifts will result in small change in average intensity. If the window consists of edge then shifts along the edge will produce small change while shifts perpendicular to edge will produce a large change, If the windowed patch consits of a corner or isolated point then all shifts will result in large change.

E (x; y ) =

jI (x + u; y + v) I (u; v)j

(1)

x,y is the shift in x and y direction and u,v is pixels within the window. The set of sifts analysed are (0; 1); (1; 1); (0; 1); (1; 1). Thus expression computes the sum of derivatives in horizontal and vertical directions of a small patch centered at (u; v ). If the minimum value of E (x; y ) is above a threshold we mark the pixel (u; v ) are desired corner. This implies that if the magnitude of derivative along vertical and horizontal direction are above a certain threshold it is marked as desired corner. Such a point corresponds to isolated pixel or corner.

4 | 9

Feature Detection - Harris Corner Detector Consider First order approximation of I (x + u; y + v )

I (x + u; y + v ) = I (u; v ) + x E (x; y ) = E (x; y ) = E (x; y ) =

@I @x

+ y @y
@I

P( P( P(

u;v )

jx

@I @x

+ y @y
@I

u;v )

jxX + yY j
X 2 + y2

u;v )

x2 X 2 + y 2 Y 2 + 2xyXY

E (x; y ) = x2

P(

u;v )

P(

u;v )

Y 2 + 2xy

P(

u;v )

XY

(2)

E (x; y ) = Ax2 + By 2 + 2Cxy E (x; y ) = x y E (x; y ) =


A C C B
!

x y

x x y M where M is 2 x 2 matrix y

Let us analyze the eigen values of the matrix which again are indicative of the strength of derivative and edge orientation along the x and y direction. If the window has constant intensity the eigen values will be small as derivatives will be small. If one eigen value is large while other is small it indicates a edge and indicates windows contains a linear edge. If both eigen values are large then it indicates a corner or isolated point . Thus we have to classify the point as corner based on the above criteria.

5 | 9

Feature Detection - Harris Corner Detector


4 A A C C G= C B C B
2

E=
(A

) (B ) (C )

=0

2 (A + B ) + (AB ) (C )2 = 0 2 (A + B ) + (AB ) C 2 = 0 2 (T r(M )) + det(M ) = 0 =


T r (M )+

T r (M )2 4

p p

(3)

det(M )

1 = 0:5 T r(M ) 2 = 0:5 T r(M ) + T r(M ) = 1 + 2 det(M ) = 1 1

0:25

T r(M ) det(M )
2

0:25

T r(M ) det(M )
2

det(M ) will be small if any one of eigen values is small det(M ) will be large if both eigen values are large. T r(M ) will be large only if one/both of eigen values are large
In the original paper they construct a measure to test if eigen values are large called response function

R = Det(M ) kT r(M )2

(4)

Amplitue of response function is plotted for various values of eigen values and different type of region flat,edge,corners were analysed and emprical values of k was determined to be 0.04. Also if image contrast changes due to illumination etc the reponse function amplitude increases.Thus we need to define what we mean by small amplitude of response function. R is positive in the corner regions ,negative in the edge regions and small in the flat regions.

6 | 9

Feature Detection - Harris Corner Detector Thus the first task of feature detector is to detector points for which response function gives large values.

0.4 Corner Filtering


The next Step of the algorithm is corner filtering.We are required to return a specified subset of detected corners. The approach for corner filtering is same as that of good features to track. In the first stage we divide image into blocks and select the corner with maximum response function in the block that are above a specified threshold. the threshold is choose to be some factor of maximum values of response function observed over the image. In the next step we select the corners with storngest response function that are at minimum distance. The Haris corner detector feature detector is sparse compared to good features to track feature detector since it only detects corner points as compared to corner as well as edge points. Feature returned by harris corner detector can be considered as subset of feature returned by good feature to track feature detector.

0.5 Implementation
The factor used for response function thresholding is called quality level and is choosen to be 1/100 of maximum value by defaul. The block size is window size of the path which is used for computation of the elements of matrix M. The minDistance is the minimum distance between adjancent corner pixels and the cell size over which local maximum is choosen.

7 | 9

Feature Detection - Harris Corner Detector

0.6 Code
we define a main feature_detector base class containing methods and data common to all feature detector. the harris_corner class is derived class containing specific implementations of algorithms. The code OpenCV code can be found in code repository https://github.com/pi19404/m19404/tree/master/FEATURE_DETECTOR or https://code.google.com/p/m19404/source/browse/FEATURE_DETECTOR/

8 | 9

Bibliography

Bibliography
[1] Chris Harris and Mike Stephens.  A combined corner and edge detector. In: In
Proc. of Fourth Alvey Vision Conference.

1988, pp. 147151.

[2]

Jianbo Shi and C. Tomasi.  Good features to track. In: Computer Vision and
Pattern Recognition, 1994. Proceedings CVPR '94., 1994 IEEE Computer Society Conference on.

1994, pp. 593 600.

doi: 10.1109/CVPR.1994.323794.

9 | 9