Haar-like Features

Source: Internet
Author: User
Tags rsat

Reference documents:

"1" Viola P, Jones M. Rapid object detection using a boosted cascade of simple features[c]//computer Vision and Pattern Rec Ognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on. IEEE, 2001, 1:i-511-i-518 Vol. 1.

"2" Lienhart R, Maydt J. An extended set of Haar-like features for rapid object detection[c]//image processing. 2002. Proceedings. 2002 International Conference on. IEEE, 2002, 1:i-900-i-903 Vol. 1.

"3" Zhang W Z, Tong R F, Dong J x. Boosted cascade of scattered rectangle features for object Detection[j]. Science in the China Series f:information Sciences, 2009, 52 (2): 236-243.

Haar features of Image feature extraction from target detection (c)

[Email protected]

Http://blog.csdn.net/zouxy09

1. Haar-like characteristics

The Haar-like feature was first applied to face expression by Papageorgiou and so on, and Viola and Jones were based on the use of 3 types of 4 forms of features.

Haar features are divided into three categories: Edge features, linear features, central features, and diagonal features, which are combined into feature templates. The feature template has both white and black rectangles, and defines the template's characteristic values as white rectangle pixels and minus black rectangle pixels and. The Haar characteristic value reflects the gray-level change of the image. For example: Some features of the face can be described by a simple rectangular feature, such as: The eye is darker than the cheek color, the nose bridge on both sides of the bridge than the color to deep, mouth than the surrounding color to be deep. But the rectangle feature is sensitive to some simple graphic structures, such as edges and segments, so it can only describe the structure of a particular trend (horizontal, vertical, diagonal).

For the characteristics of a, B and D in the figure, the characteristic numerical formula is: V=sum white-sum Black, and for C, the formula is as follows: V=sum white -2*sum black; the black area pixels and multiplied by 2 are to match the number of pixels in the two rectangular regions.

By changing the size and position of the feature template, a large number of features can be quoted in the Image sub-window. Feature template is called "feature prototype"; The feature prototype expands in the image Subwindow (translation scaling) The resulting features are called "rectangular features", and the values of the rectangular features are called "eigenvalues".

Rectangular features can be anywhere in the image, and the size can be arbitrarily changed, so the rectangular eigenvalue is a rectangular template category, rectangular position and the size of the rectangle three factors of the function. Therefore, the category, size and position changes, so that very small detection window contains a lot of rectangular features, such as: In the 24*24 pixel size of the detection window within the number of rectangular features can reach 160,000. So there are two problems to solve: (1) How to quickly calculate so many features? ---integral graph prowess; (2) which rectangular features are most effective for classifier classification? ---such as the adaboost algorithm to train (this piece is not discussed here, specifically see http://blog.csdn.net/zouxy09/article/details/7922923)

2. Calculation of Haar-like features-integral graph

The integral graph is a fast algorithm that can find all the pixels in the image and the efficiency of the image eigenvalue calculation by traversing only one image.

The main idea of the integral graph is that the pixels of the rectangular region formed from the starting point of the image to each point are stored in memory as an element of an array, and the elements of the array can be indexed directly when the pixels of an area are computed, without recalculating the pixels of the region and speeding up the calculation (this has a corresponding salutation, Called dynamic programming Algorithms). The integration graph can be used to calculate different characteristics at various scales using the same time (constant time), so the detection speed is greatly improved.

Let's see how it's done.

Integral graph is a kind of matrix representation method which can describe global information. The integral graph is constructed by the value of position (I,J) II (I,J) is the same as all pixels in the upper-left direction of the original image (I,J):

Integration Graph Construction Algorithm:

1) use S (i,j) to denote the summation of the line direction and initialize S (i,-1) = 0;

2) Use II (I,J) to represent an integral image, Initialize II ( -1,i) = 0;

3) Progressive scan of the image, recursive calculation of each pixel (i,j) line direction of the summation and S (i,j) and Integral Image II (I,J) values

S (i,j) =s (i,j-1) +f (I,J)

II (I,J) =ii (i-1,j) +s (I,J)

4) Once the image is scanned, the integral Image II is constructed when the pixel in the lower right corner of the image is reached.

After the integral graph is constructed, the pixel summation of any matrix region in the image can be obtained by simple operation.

The four vertices of D are α, β, γ, δ, then the pixels of D and can be expressed as

Dsum = II (α) +ii (β)-(II (γ) +ii (δ));

The Haar-like eigenvalue is nothing more than two matrix pixels and the difference, can also be completed in constant time. Therefore, the eigenvalue calculation of a rectangular feature is only related to the integral graph of the vertex of this feature rectangle, so no matter how the scale transformation of this feature rectangle is, the time spent on the calculation of the eigenvalues is constant. This allows the eigenvalues of all child windows to be evaluated as long as the image is traversed once.

3. Haar-like Rectangle Feature Expansion

Lienhart R. The Haar-like Rectangle feature Library is further expanded, and the rotation 45 is added. The rectangle feature of the corner. The expanded features are broadly divided into 4 types: Edge feature, line feature ring, center surround feature, and diagonal feature:

During the calculation of the eigenvalues, the weights of the black areas are negative, and the weights of the white areas are positive values. And the weights are inversely proportional to the rectangular area (so that the number of pixels in the two rectangular regions is consistent);

Vertical matrix Eigenvalue calculation:

For the vertical matrix, the same as above 2.

Calculation of the rectangular features of 45° rotation angle:

For a rectangle with a rotation angle of 45°, we define the pixels of rsat (x, y) to the upper-left corner of the 45° area and the lower-left corner of the 45° area.

The formula can be expressed as:

In order to save time and reduce the repetition calculation, the following recursive formula can be calculated as follows:

The characteristic value of the computed matrix feature is the difference between the RSAT (x, y) of the cross-row rectangle. Refer to:

Haar-like Features

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.