
function res=proces(inp,blksize)
% 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. 
perc=0.75 % autocorrelation percentage for filterwidth
fact1=0.02;
fact2=0.05;
[rg,cg]=size(inp);
res(rg,cg)=0;
filtsize=(corper(inp',perc)-1)/2
ib=1;
is=blksize;
blkcnt=1;
offs=0;
prehis=zeros(1,cg);
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=prehis/4;
[his,ofar]=dyhghn(p,stp,prehis);
hispre=his; % current histogram becomes previous
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;
% save the lines corrected for the shifts
if (offs > 0)
	linsep(blkcnt,1:cg-offs)=s(offs+1:cg)';
else
	linsep(blkcnt,1-offs:cg)=s(1:cg+offs)';
end;
%linsep(blkcnt,100:120)
blkcnt=blkcnt+1;
if (filtsize > 5) s=unif(s',1)'; end;
count=1;
for io=(ib:stp:ie);
	pos=ofar(count);
	if (pos >0)
	        for ios=io:io+stp;
		res(ios,pos+1:cg)=s(1:cg-pos)';
		linsft(io) = offs+pos;
		end; 
	else
		for ios=io:io+stp;
		res(ios,1:cg+pos)=s(1-pos:cg)';
		linsft(io) = offs+pos;
		end;
	end;
	count=count+1;
end; % write results back in res
offs=offs+pos;
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;

