function nout = nmaxs2(f,k)
%  nout = nmaxs2(f)
%  non-maxima suppression
%      f: 2D image
[m,n] = size(f);
nout = zeros(m,n);
k2 = (k-1)/2;
for i1 = k2+1:m-k2
  for j1 = k2+1:n-k2
    val = f(i1,j1);
	vmax = max(max(f(i1-k2:i1+k2,j1-k2:j1+k2)));
	if val>=vmax
	  nout(i1,j1) = val;
	end
  end
end
