自己想的积分图代码

来源:互联网 发布:数据的概念 编辑:程序博客网 时间:2024/06/05 09:35

II(x,y)——所求积分图

 I(x,y)——原灰度图

s(x,y)——(x,y)所在点的列(x,y)以上的灰度之和

代码:

int i,j;

int s=(int*)malloc((height+1)*(width+1)*sizeof(int));

int II=(int*)malloc((height+1)*(width+1)*sizeof(int));

for( j=0 ; j<=height ; j++)

II(-1,j)=0;

for(i=0;i<=width;i++)

s(i,-1)=0;

for(i=0;i<=width;i++)

{

for(j=0;j<=height;j++)

{

s(i,j) = s(i,j-1) + I(i,j);

II(i,j) = II(i-1,j) +s(i,j);

}

}


0 0
原创粉丝点击