Image integration diagram and its realization in machine vision

Source: Internet
Author: User

Face Detection (Detection) is a common task in computer vision. Paul Viola and Michael Jones in the article "Rapid object detection using a Boosted cascade ofsimple features," The Fast object recognition algorithm brings face detection to a new height, This real-time face detection system, which combines adaboost and cascade algorithms, makes face detection more practical and valuable. In order to accelerate the calculation of Haar features, they put forward the concept of integral graph.


The integral graph of the coordinate point (x, y) is defined as the sum of the pixel values in the upper-left corner of the graph in which they correspond:


where II(x,y) represents the integral graph of the pixel point (x, y),i(x, y) represents the original image. For example, the simplest way to calculate an integral graph in MATLAB is to use the cumsum and function. A simple example code is given below.


>> m = [1, 2, 3;        4, 5, 6;        7, 8, 9]m =     1     2     3     4     5     6     7     8     9>> cumsum (Cumsum (M, 2), 1) ans = 1 3 6 5 12 21 12 27 45

But as you can imagine, if you calculate the integral graph of an image by definition, the amount of computational growth is staggering as the size of the image expands. Fortunately, we can use a more efficient method to calculate the integration graph. II (x,y) is calculated by the following iteration:s(x, y) = s(x, y ? 1) +i(x,y),II(x, y) = II( x-1, y) +s(x,y), where s(x,y) Represents the integral of the line and s(x,-1) =0,II( -1, y) = 0. To find the integral of an image, you simply traverse the image once.

Integral chart element value calculation: The above formula shows that the value of the integral graph of the midpoint "1" is the sum of the pixel values of all the pixels in the rectangle box A. The point "2" of the integration chart corresponds to the value of A+b, the point "3" is a+c, the point "4" is a+b+c+d, so the sum of all the pixel values in D can be calculated with 4+1-(2+3). It is also the basic principle of using integral graph to realize fast calculation of Haar features. Assuming that the coordinates at point 4 are (x, y ), it is possible to know that the formula for the integration Graph II ( x , y) at point 4 is II Y) + II (x-1, y) + II (x, y-1)-II (X-1, y-1), This formula corresponds to D + (A+c) + (a+b)-A = a + B + C + D in the diagram.

The MATLAB code shown below is used to calculate the integral graph using the above principles.

>> [w h] = size (m);>>% compute integral graph I=zeros (w,h); for i=1:w for    j=1:h        if i==1 && j==1             % integral image upper left corner 
   i (i,j) =m (i,j);        ElseIf i==1 && j~=1         % integral image first line            I (i,j) =i (i,j-1) +m (i,j);        ElseIf i~=1 && j==1         % integral image first column            I (i,j) =i (i-1,j) +m (i,j);        else                        % integral image other pixels            I (i,j) =m (i,j) +i (i-1,j) +i (i,j-1)-I (i-1,j-1);          End    Endend>> II =     1     3     6     5    45


It can be seen that this is consistent with the result of the previous definition.


Image integration diagram and its realization in machine vision

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.