function [his,offs]=dyhough(p);
[r,c]=size(p);
his=zeros(1,r);
offs=0;
for io=1:c;
	sum1=0;
	sum2=0;
	sum3=0;
	for jo=1:r;
		pos=jo+offs;
		if (pos >=2) & (pos <=r-1)
		sum1=max(his(jo)*p(pos-1,io),sum1);
		sum2=max(his(jo)*p(pos,io),sum2);
		sum3=max(his(jo)*p(pos+1,io),sum3);
		
		end;
	end;
	if (sum1>=sum2) & (sum1>=sum3) offs=offs-1; end;
	if (sum3>=sum2) & (sum3>=sum1) offs=offs+1; end;
        for jo=1:r;
                pos=jo+offs;
		if (pos>=1) & (pos<=r)
                his(jo)= his(jo)+p(pos,io);
                end;
        end;
end;
end;

