
load genel.table;
tic;
[rg,cg]=size(genel);
res(cg,rg)=0;
ib=1;
is=30;
while ib<rg	
ie=min(ib+is,rg);
g=genel(ib:ie,:)';	% tranpose matrix
toc
h=maxmat(g,2);	% maximaum filter over the columns
toc
u=h-g;		% difference image between maxfiltered and original
%imshow(u);
F=ones(5,30);
p=conv2(u,F,'same');
%p=medfilt2(u,[4,30],size(u));
q=maxpos(p,2);	% find local maxima and minima in the columns
toc
imshow(q);
%his=sum(q');
% s=maxpos(his',4);
%for io=1:79; t(:,io)=s(:); end;
%figure;
%imshow(t);
%%%%%
%figure;
%combo(g,t);
[a,b]=maxline(q,1,1)	% do a line approximation to the maxima
toc
[c,d]=maxline(q,-1,1)	% do a line approximation to the minima
[r,c]=size(q);
t=wrtlin(a,b,r,c);	% write the lines in the image
toc
%figure;
combo(g,t);
res(:,ib:ie)=t;
ib=ib+is;
end;
combo(genel',res);



