This is often used to calculate Haar features.
Wiki has a very good introduction. I turned to the following shame:
Each point of the integral graph (X,Y) Is the sum of all values in the upper-left corner of the source image:
In addition, the integral graph can be effectively calculated by traversing the image only once, because each point of the integral graph (X,Y) Value:
Once the integral graph is calculated, the sum of any rectangle can be calculated within the constant time. For example, the value of the Shadow rectangle area is as follows:
Clear all; close all1_clc1_img1_double(imread('lena.jpg '); [m n] = size (IMG); % calculate the integral graph I = zeros (m, n); for I = 1: M for j = 1: n if I = 1 & J = 1% integral image upper left corner I (I, j) = IMG (I, j ); elseif I = 1 & J ~ = 1% integral image first line I (I, j) = I (I, J-1) + IMG (I, j); elseif I ~ = 1 & J = 1% integral image first column I (I, j) = I (I-1, j) + IMG (I, j ); else % integral image other pixel I (I, j) = IMG (I, j) + I (I-1, j) + I (I, J-1)-I (I-1, J-1 ); end endend % How to Use I depends on the situation