function K=kernel_gauss(varargin)
%--------------------------------------------------------------------------
% kernel_gauss function                                            ImBasic
% Description: Generate a Gaussian kernel with zero background and
%              normalized to unity sum.
%              OBSOLETE: Use Kernel2.gauss instead.
% Input  : - SigmaX of Gaussian. Default is 1.5 pix.
%          - SigmaY of Gaussian. Default is 1.5 pix.
%          - Rho of Gaussian. Default is 0.
%          - Stamp size in X direction. Default is 11.
%          - Stamp Size in Y direction. Default is 11.
% Output : - A Gaussian kernel located at the stamp center.
%            The stamp center is defined to be the middle of the central
%            pixel (i.e., delta function span over one pixel), where the
%            central pixel is give by ceil(Size./2 + 0.1).
% See also: kernel_aper.m, kernel_annulus.m, kernel_exp.m
% License: GNU general public license version 3
% Tested : Matlab R2015b
%     By : Eran O. Ofek                    Jun 2016
%    URL : http://weizmann.ac.il/home/eofek/matlab/
% Example: K=kernel_gauss;
% Reliable: 2
%--------------------------------------------------------------------------

%         SigmaX SigmaY Rho SizeX SizeY
DefPar = [1.5, 1.5, 0, 11, 11];
Nvar   = numel(varargin);
Par    = [varargin{:}, DefPar(Nvar+1:end)];
SigmaX = Par(1);
SigmaY = Par(2);
Rho    = Par(3);
SizeX  = Par(4);
SizeY  = Par(5);

[MatX,MatY] = meshgrid((1:1:SizeX),(1:1:SizeY));
X0  = ceil(SizeX.*0.5+0.1);
Y0  = ceil(SizeY.*0.5+0.1);
MatX = MatX - X0;
MatY = MatY - Y0;

K = 1./(2.*pi.*SigmaX.*SigmaY.*sqrt(1-Rho.^2)) .* ...
                       exp(-1./(2.*(1-Rho.^2)) .* ...
 	                       (MatX.^2./SigmaX.^2 + ...
                            MatY.^2./SigmaY.^2 - ...
				2.*Rho.*MatX.*MatY./(SigmaX.*SigmaY)));

