function b = bprops(bands, image, icr, ich, icx)
% b = bprops(bands, image, icr, ich, icx)
%     Calculate some properties of bands
[mb nb] = size(bands);
[m n] = size(image);
b = bands;
for i1 = 1:mb     % for every band
  ival = bands(i1,1);           % get row number
  jstart = max(1,round(bands(i1,5)));    % get start column for band
  jend   = min(n,round(bands(i1,6)));    % get end column for band
  gsum = 0; rsum = 0; hsum = 0; count = 0;
  for jval = jstart:jend
    gsum = gsum + image(ival,jval);
    if icx(ival,jval) ~= 0
      count = count+1;
      rsum = rsum + icr(ival,jval);
      hsum = hsum + ich(ival,jval);
    end
  end
  nval = (jend-jstart+1);
  b(i1,9) = 0; b(i1,10) = 0;
  b(i1,8) = gsum/nval;
  if count>0
    b(i1,9) = rsum/count;
    b(i1,10) = hsum/count;
  end
end
