function b = seg0(labimg)
%
% seg0 - calculate segment centers
% On input:
%     labimg: labeled image
% On output:
%     b: segment centers (row,col), and size (numsegs by 3)
% Call:
%    b = seg0(labimg);
%

numsegs = max(max(labimg));
b = zeros(numsegs,3);
[m,n] = size(labimg);
for r = 1:m
  for c = 1:n
    lab = labimg(r,c);
    if lab ~= 0
	  b(lab,1) = b(lab,1)+r;
	  b(lab,2) = b(lab,2)+c;
	  b(lab,3) = b(lab,3)+1;
	end
  end
end
for s = 1:numsegs
  if b(s,3) ~= 0
    b(s,1) = b(s,1)/b(s,3);
	b(s,2) = b(s,2)/b(s,3);
  end
end
