
function res=proces(inp,blksize,filtsize,fact1,fact2)
% this function finds the separation between bands, based upon max-min 
% filtering.
% parameters:
% inp : input image
% res : result image inwhich the separation pixels are 1
% blksize : the bloksize in which the image is divided up and in which
% 	separation rows are found
% filtsize : filtersize of the smoothing (2* filtsize+1)
% fact : local maximum/minimum definition.
%
tic;
stp=20; % defined by max angle +/- 3 graden. 
[rg,cg]=size(inp);
res(rg,cg)=0;
ib=1;
is=blksize;
while ib<rg	
ib
ie=min(ib+is-1,rg);
g=inp(ib:ie,:)';	% tranpose matrix
% max-min filter over the columns
p=maxfil(g,filtsize)-minfil(g,filtsize);
%imshow(p);
[his,ofar]=dynhgh(p,stp);
totmx=max(his);
ofar
s=maxpos(his',fact1);	% find wich rows are local maxima
% throw out small maxima
for jo=1:cg; if (his(jo) < fact2*totmx) s(jo) = 0; end; end;
if (filtsize > 5) s=unif(s',1)'; end;
count=1;
for io=(ib:stp:ie);
	pos=ofar(count);
	for ios=io:io+stp;
		if (pos >0)
		res(ios,pos+1:cg)=s(1:cg-pos)';
		else
		res(ios,1:cg+pos)=s(1-pos:cg)';
		end;
	end;
	count=count+1;
end; % write results back in res
toc
ib=ib+is;		% next part
end;
combo(inp,res);
axis normal;
text(0,-50,['row: ',num2str(blksize),' column: ',num2str(filtsize),' fact1: ',num2str(fact1),' fact2: ',num2str(fact2)]);
colormap(cool);
toc
end;

