function [rb, resultm] = exban(image,rsamp,csamp,Krow,Kcol,Kthin)
%
[m n] = size(image);
indexb = 0;
remc = rem(n,csamp)
remr = rem(m,rsamp)
nc = (n-remc)/(csamp)
nr = (m-remr)/(rsamp)
for n1 = 1:nr
  i1 = (n1-1)*rsamp + 1;
  for n2 = 1:nc
    j1 = (n2-1)*csamp + 1;
    [bnds,bmsk] = pbands(image(i1:i1+rsamp-1,j1:j1+csamp-1),Krow,Kcol,Kthin);
    [bm bn] = size(bnds);
    for index1 = 1:bm
      indexb = indexb+1;
      for index2 = 1:20
        rb(indexb,index2) = bnds(index1,index2);
      end
    end
  end
end
if remc > 0
  for n1 = 1:nr
    i1 = (n1-1)*rsamp+1;
    j1 = n-csamp+1;
    [bnds,bmsk] = pbands(image(i1:i1+rsamp-1,j1:j1+csamp-1),Krow,Kcol,Kthin);
    [bm bn] = size(bnds);
    for index1 = 1:bm
      indexb = indexb+1;
      for index2 = 1:20
        rb(indexb,index2) = bnds(index1,index2);
      end
      rb(indexb,15) = rb(indexb,15)+i1;
      rb(indexb,16) = rb(indexb,16)+j1;
    end
  end
end
if remr>0
  for n2 = 1:nc
    i1 = m-rsamp+1;
    j1 = (n2-1)*csamp+1;
    [bnds,bmsk] = pbands(image(i1:i1+rsamp-1,j1:j1+csamp-1),Krow,Kcol,Kthin);
    [bm bn] = size(bnds);
    for index1 = 1:bm
      indexb = indexb+1;
      for index2 = 1:20
        rb(indexb,index2) = bnds(index1,index2);
      end
      rb(indexb,15) = rb(indexb,15)+i1;
      rb(indexb,16) = rb(indexb,16)+j1;
    end
  end
end
if remc>0 & remr>0
  i1 = m-rsamp+1;
  j1 = n-csamp+1;
  [bnds,bmsk] = pbands(image(i1:i1+rsamp-1,j1:j1+csamp-1),Krow,Kcol,Kthin);
  [bm bn] = size(bnds);
  for index1 = 1:bm
    indexb = indexb+1;
    for index2 = 1:20
      rb(indexb,index2) = bnds(index1,index2);
    end
    rb(indexb,15) = rb(indexb,15)+i1;
    rb(indexb,16) = rb(indexb,16)+j1;
  end
end
