function genintmat(img)

global intmat intmat1

[dx,dy]=sdxy(img); grad=sqrt(dx.^2+dy.^2);
[dy,dx]=sdxy(grad);
[dxy,junk]=sdxy(dy);
z=zeros(4,4);

for i=3:126,
	for j=3:126,
		x=[[grad(i,j) grad(i+1,j) grad(i+1,j+1) grad(i,j+1)] ...
		[dx(i,j) dx(i+1,j) dx(i+1,j+1) dx(i,j+1)] ...
		[dy(i,j) dy(i+1,j) dy(i+1,j+1) dy(i,j+1)] ...
		[dxy(i,j) dxy(i+1,j) dxy(i+1,j+1) dxy(i,j+1)]]';
		y=intmat1*x;
		z(:)=y; z=z';
		intmat(:,(j-1)*128+i)=z(:);
	end
end
