function out = nms1(f,K)
%
% nms1: non-maxima suppression in local area
% On input:
%     f: 2D image
%     K: window dimension for comparing values
% On output:
%     out: local maxima (in column of length K)
% Call:
%     out = nms1(f,K)
%

[m,n] = size(f);
out = zeros(n,m);
Kradius = (K-1)/2;
for i1 = Kradius+1:m-Kradius
  for j1 = 1:n
     win = f(i1-Kradius:i1+Kradius,j1);
     maxw = max(max(win));
     if f(i1,j1) >= maxw
	out(i1,j1) = f(i1,j1);
     end;
  end;
end;

