%%get the integral image
function result=wzzh_get_integral(image)
tic;
[height,width]=size(image);
A=image;
%计算积分图
I=zeros(height,width);
uint8 s=0;
% for i=1:height
% for j=1:width
% if i==1 && j==1 %积分图像左上角
% I(i,j)=A(i,j);
% elseif i==1 && j~=1 %积分图像第一行
% I(i,j)=I(i,j-1)+A(i,j);
% elseif i~=1 && j==1 %积分图像第一列
% I(i,j)=I(i-1,j)+A(i,j);
% else %积分图像其它像素
% I(i,j)=A(i,j)+I(i-1,j)+I(i,j-1)-I(i-1,j-1);
% end
% end
% end
for i=1:height
for j=1:width
s=sum(A(1:i,j));
if(j-1<=0)
I(i,j) = s;
else
I(i,j)=s+I(i,j-1);
end
s=0;
end
end
result=I;
toc;
%%this method is checked out.