function K=kernel_exp(varargin)
%--------------------------------------------------------------------------
% kernel_exp function                                              ImBasic
% Description: Generate an exponential radial kernel with zero background 
%              and normalized to unity sum.
%              OBSOLETE: Use Kernel2.exp instead.
% Input  : - Exponential scale radius. Default is 3 pix.
%          - Stamp size in X direction. Default is 21.
%          - Stamp Size in Y direction. Default is 21.
% Output : - An exponential 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).
% 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_exp;
% Reliable: 2
%--------------------------------------------------------------------------



%         Radius SizeX SizeY
DefPar = [3, 21, 21];
Nvar   = numel(varargin);
Par    = [varargin{:}, DefPar(Nvar+1:end)];
Radius = Par(1);
SizeX  = Par(2);
SizeY  = Par(3);

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

MatX = MatX - X0;
MatY = MatY - Y0;
MatR2=MatX.^2 + MatY.^2;

K = exp(-sqrt(MatR2)./Radius);
K = K./sum(K(:));


