Corner detection: Harris corner Point and Shi-tomasi Corner detection

Source: Internet
Author: User
Tags scalar
2012-07-31 13:25 Corner Point

Feature detection and matching is an important part of the computer Vision application, which needs to find the characteristics of the image to establish the corresponding relationship. Point, which is the special position in the image, is a very common feature, the local feature of the point can also be called "key feature Point" (KeyPoint feature), or "point of interest" (interestpoint), or "Corner" ( Conrner).

The specific description of the corner point can be several: the first-order derivative (that is, the gradient of the gray scale) of the local maximum pixel points; two and two edges of the intersection point; the gradient and gradient direction of the image of the change rate are very high points; the first derivative of the corner is the largest and the second derivative is zero, indicating the direction of

Harris Corner Point detection

When a window moves on the image, in the smoothed area as shown in figure (a), the window does not change in all directions. On the edge as shown in figure (b), the window has no change in the direction of the edge. At the corner point as shown in figure (c), the window changes in all directions. Harris Corner Point Detection is the use of this intuitive physical phenomenon, through the window in all directions of the degree of change, determine whether it is a corner point.

Translate the image window [u,v] to produce a grayscale change E (u,v)

By:, Get:

For a locally small amount of movement [u,v], the approximate expression is:

where M is the 2*2 matrix, it can be obtained from the derivative of the image:

The oval shape of E (U,V) is shown below:

Define the corner response function R as:

Harris Corner Point detection algorithm is the diagonal point response function R for threshold processing: R > Threshold, that is, the local maximum value of the extracted R.

"Related Code"

The Cornerharris function is defined in OPENCV: [CPP] view plain copy void Cornerharris (Inputarray src, outputarray dst, int BlockS ize, int ksize, double k, int bordertype=border_defaul T);

You can combine the Convertscaleabs function to take a corner point from a threshold value: [CPP]   View plain copy Void cornerharris_demo ( int, void* )    {      Mat dst, dst_norm;     dst = mat::zeros ( src.size (), &NBSP;CV _32fc1 );     /// Detector parameters     int  blocksize = 2;     int apertureSize = 3;      double k = 0.04;     /// Detecting corners      Cornerharris ( src_gray, dst, blockSize, apertureSize, k, BORDER_DEFAULT );      /// Normalizing     normalize ( dst, dst_norm, 0 ,  255, norm_minmax, cv_32fc1, mat ()  );     convertscaleabs (  dst_norm, dst_norm_scaled );      /// Drawing a circle  Around corners     for ( int j = 0; j < dst_norm.rows  ; j++ )         { for ( int i = 0;  i < dst_norm.cols; i++ )               {               if (   (int)  dst_norm.at<float> (j,i)  > thresh )                   {                     circle ( dst_norm_scaled,  Point ( i, j ),  5,  scalar (0), 2, 8, 0 );                    circle (SRC, Point ( i, j ), &NBsp;5,  scalar (255,0,0), -1, 8, 0 );                  }              }         }          /// Showing the result     imshow ( corners_window, dst_norm_ scaled );     imshow ( source_window, src );    }   


Shi-tomasi Algorithm

The Shi-tomasi algorithm is an improvement of the Harris algorithm. The most primitive definition of the Harris algorithm is to subtract the determinant of the matrix M from the trace m, and then compare the difference with the pre-given threshold value. Later, Shi and Tomasi proposed an improved method, if the smaller one of the two eigenvalues is greater than the minimum threshold, a strong corner will be obtained.

As shown in the second image above, the eigenvalue analysis is performed on the autocorrelation matrix M, resulting in two eigenvalues and two characteristic direction vectors. Because the larger uncertainty depends on the smaller eigenvalues, that is, the search for a good feature point by finding the maximum value of the minimum eigenvalue is explained.
The methods of Shi and Tomasi are quite adequate, and in many cases, better results can be obtained than using the Harris algorithm.

"Related Code"

Since this shi-tomasi operator is proposed in 1994 in article good Features to track [1], the function name of the algorithm OpenCV implements is defined as Goodfeaturestotrack:[CPP]  View plain copy void goodfeaturestotrack ( inputarray image, outputarray corners,                                           int maxCorners, double qualityLevel, double minDistance,                                           inputarray mask=noarray (), int blocksize=3,                                          bool  Useharrisdetector=

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.