www.gusucode.com > vision 源码程序 matlab案例代码 > vision/ComputeAnIntegralImageExample.m

    %% Compute an Integral Image
% Compute the integral image and use it to compute the sum of pixels over a rectangular region of an intensity image.
%%
% Create an image matrix.
I = magic(5)
%%
% Define rectangular region as [startingRow, startingColumn, endingRow, endingColumn].
[sR sC eR eC] = deal(1,3,2,4);
%%
% Compute the sum over the region using the integral image.
J = integralImage(I);
regionSum = J(eR+1,eC+1) - J(eR+1,sC) - J(sR,eC+1) + J(sR,sC)