function K=kernel_annulus(varargin)
%--------------------------------------------------------------------------
% kernel_annulus function                                          ImBasic
% Description: Generate an annulus circular kernel with zero
%              background and normalized to unity sum.
%              OBSOLETE: Use Kernel2.annulus instead.
% Input  : - Annulus inner radius. Default is 5 pix.
%          - Annulus outer radius. Default is 7 pix.
%          - Stamp size in X direction. Default is 15.
%          - Stamp Size in Y direction. Default is 15.
% 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).
% 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_annulus;
% Reliable: 2
%--------------------------------------------------------------------------


%         InnerRadius OuterRadius SizeX SizeY
DefPar = [5, 7 15, 15];
Nvar   = numel(varargin);
Par    = [varargin{:}, DefPar(Nvar+1:end)];
InRad  = Par(1);
OutRad = Par(2);
SizeX  = Par(3);
SizeY  = Par(4);

[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 = zeros(SizeY,SizeX);
K(MatR2>InRad.^2 & MatR2<=OutRad.^2) = 1;
K = K./sum(K(:));
