function res=proclin(inp,filtrow,filtcol,gapsize)
% this function finds the separation between bands, based upon maximum
% filtering and line approximation.
% parameters:
% inp : input image
% res : result image inwhich the separation pixels are 1
% filtrow : ifiltersize of the smoothing (2* filtsize+1i) in the rows.
% filtcol : filtersize of the smoothing (2* filtsize+1) in the columns,
% gapsize : gap in rows allowed for the same separation line.
%
tic;
[rg,cg]=size(inp);
res(rg,cg)=0;
blksize=filtcol*2+1;
ib=filtcol+1;
is=blksize;
while ib<rg-filtcol	
ie=min(ib+is-1,rg-filtcol);
ifb=ib-filtcol;
ife=ie+filtcol;
g=inp(ifb:ife,:)';	% tranpose matrix
h=maxmat(g,filtrow);	% maximaum filter over the columns
u=h-g;		% difference image between maxfiltered and original
%imshow(u);
F=ones(2*filtrow+1,blksize);
p=conv2(u,F,'same');
%p=medfilt2(u,[4,30],size(u));
q=maxpos(p(:,filtcol+1:filtcol+1+ie-ib),filtrow);	
% find local maxima and minima in the columns
%imshow(q);
[a,b]=maxline(q,1,gapsize);	% do a line approximation to the maxima
[c,d]=maxline(q,-1,gapsize);	% do a line approximation to the minima
[r,c]=size(q);
t=wrtlin(a,b,r,c);	% write the lines in the image
%combo(g,t);
res(ib:ie,:)=t';
ib=ib+is;
toc
end;
end;


