function r = relmax(f,K1,K2)
% r = relmax(f,K1,K2)
[m n] = size(f);
r = zeros(m,n);
k1 = (K1-1)/2;
k2 = (K2-1)/2;
for i1 = 1+k1:m-k1
  for j1 = 1+k2:n-k2
    val = f(i1,j1);
    ismax = 1;
    for i2 = -k1:k1
      for j2 = -k2:k2
        if val < f(i1+i2,j1+j2)
          ismax = 0;
          break;
        end
        if ismax<1
          break;
        end
      end
      if ismax<1
        break;
      end;
    end
    if ismax == 1
      r(i1,j1) = 255;
    end
  end
end

