function [tbd_array,npt]=blob_track(ABX,ABX_tau,c_thresh)
%
iifig=0;
[nD,nbrg,ntime]=size(ABX.data);
data=zeros(nD,nbrg);
iiD0=[1:nD]; iiD1=[1,1:nD-1]; iiD2=[2:nD,nD];
iib0=[1:nbrg]; iib1=[1,1:nbrg-1]; iib2=[2:nbrg,nbrg];
% Initialize array of blob information:
npt_max=15*ntime; tbd_array=zeros(npt_max,5); npt=0;
brg_ax=ABX.x(:); D_ax=ABX.y(:); t_ax=ABX.z(:);
for jt=1:ntime,
	data(:,:)=ABX.data(:,:,jt);
%	iip1=find(data(iiD,iib) > data(iiD-1,iib) & data(iiD,iib) > data(iiD+1,iib));
	iip1=find(data(iiD0,iib0) > data(iiD0,iib1) & data(iiD0,iib0) > data(iiD0,iib2));
	iip2=find(data(iip1) > data(iip1-1) & data(iip1) > data(iip1+1) & ...
		data(iip1) > data(iip1-1) & data(iip1) > data(iip1+1) & data(iip1) > c_thresh);
	
%	iip1_D=mod(iip1-1,nD-2) + 2;
%	iip1_b=floor((iip1-1)/(nD-2)) + 2;

	iip=iip1(iip2);
	ii=find(data(iip) > data(iip-nD-1) & data(iip) > data(iip-nD+1) & ...
		data(iip) > data(iip+nD+1) & data(iip) > data(iip+nD-1));
%	nii=length(ii),
	
	iip_D=mod(iip(ii)-1,nD) + 1;
	iip_b=floor((iip(ii)-1)/nD) + 1;
	iiok=find(iip_D>1 & iip_D<nD); nok=length(iiok);
	if nok<length(iip), iip_D=iip_D(iiok); iip_b=iip_b(iiok); end
	
	iipeak=(iip_b-1)*nD + iip_D;
	cc_peak=data(iipeak);
	tau_peak=ABX_tau.data(iipeak);
	
	if iifig,
		figure(200); clf;
		imagesc(data); hold on;
		plot_cfill(iip_b,iip_D);
		keyboard
	end
% Allocate more memory if necessary:
	if npt+nok > npt_max, tbd_array=[tbd_array; zeros(100,5)]; npt_max=npt_max + 100; end
%
	tbd_array(npt+1:npt+nok,:)=[repmat(t_ax(jt),[nok,1]), brg_ax(iip_b), D_ax(iip_D), ...
		cc_peak, tau_peak];
	npt=npt + nok;
end
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
