function [time,out] = ridges(a,Kcol,Krow);
%   label topographic simple ridges in an image
%       [time,out] = ridges(a,Kcol,Krow)
%
%  ridges: uses 1D quadratic fit to extract ridge pixels
%          groups neighbors into labeled simple (no branches) ridge segments
%
%  on input:
%
%    a:     2D array of heights at pixels
%    Kcol:  number of column elements to fit parameter 
%    Krow:  number of row elements to fit parameter 
%
%  on output:
%
%    time: 	    total time for ridge finder 
%    out:	    2D array of labeled ridge segments
%
%  Authors:	Tom Henderson/Scott Morris
%		Univ of Utah
%		9 Oct 1996
%

tic

[icx,ice,ich,icr,irx,ire,irh,irr] = tgraph(a,Kcol,Krow);

rcol = ridge1(ich);

lcol = labelr8(rcol);

scol = simridge(lcol);

scol2 = simlabel(scol);

col = rthinc(scol2,ich);

%%%%%%%%%%% Switch to processing the rows image

rrow = ridge1(irh);

lrow = labelr8(rrow);

srow = simridge(lrow);

srow2 = simlabel(srow);

row = rthinr(srow2,irh);

out = row + col;

time = toc;




