function segment = pass2(prob,xrow,xcol,Krow,Kcol)
% p = pass2(prob,xrow,xcol,Krow,Kcol)
%     Thresholds probablility of pass1
[m n] = size(prob);
krow = round((Krow-1)/2);
kcol = round((Kcol-1)/2);
index = 0;
for ii = 1:m
  for jj = 1:n
    segment(ii,jj) = 0.0;
  end
end
for ii = 1:m
  for jj = 1:n
    segment(ii,jj) = 0.0;
    if prob(ii,jj) > 0
      largest = 1;
      colct = 0;
      rowct = 0;
      for i2 = ii-krow:ii+krow
        for j2 = jj-kcol:jj+kcol
          if xrow(i2,j2) > 0
            rowct = rowct+1;
          end
          if xcol(i2,j2) > 0
            colct = colct+1;
          end
          if prob(i2,j2) > prob(ii,jj)
            largest = 0;
          end
        end
      end
      if largest*colct*rowct > 0
        segment(ii,jj) = 255;
      end
    end
  end
end
