
function c = gauss_kernel(N);

% FUNCTION Y = GAUSS_KERNEL(N);
% y is an NxN 2-d matrix of Gaussian-patered correlation kernel
% N is the size of the kernel
  
  if mod(N,2)
    error('N must be an even number!');
  end;
  
  % (anti)coherenece kernel
  ker = [ones(N/2),-ones(N/2);-ones(N/2),ones(N/2)];
  
  % gaussian pyramid for smoothing
  K = 2.5;
  [x,y] = meshgrid(-K:2*K/N:K-K/N);
  z = exp(-.5*(x.^2+y.^2))/(2*pi);
  
  % smoothed kernel
  c = z.*ker;
