function g = gauss(s,K)
%
% gauss: returns the Gaussian filter normalized to unit area
% On input:
%          s is sigma
%          K is window size of Gaussian convolution kernel
% On Output:
%          g: K by K Gaussian window
% Call:
%      g = gauss(s,K)
%

k = (K-1)/2;
g = zeros(K,K);
s2 = 2*s^2;
sum = 0;
for ii = -k:k
  for jj = -k:k
    g(k+1+ii,k+1+jj) = exp(-((ii^2+jj^2)/s2));
    sum = sum + g(k+1+ii,k+1+jj);
  end
end
g = g/sum;
