Code covered by the BSD License  

Highlights from
Norton-Beer apodization filter

Norton-Beer apodization filter

by

 

24 Apr 2013 (Updated )

NORTONBEER produces a one-dimensional Norton-Beer apodization filter

nortonbeer(W,varargin)
function varargout = nortonbeer(W,varargin)
% NORTONBEER produces a one-dimensional Norton-Beer apodization filter
%
%   NORTONBEER(W) returns the W-point symmetric Norton-Beer window in a
%   column vector.
%  
%   NORTONBEER(W,C) permits custom assignment of the filter coefficients. The
%   coefficients in vector C are used to produce the filter window FILT
%   according to the following equation:
%                 ___
%       FILT(U) = \   N   C_i(1-U^2)^i
%                 /__ i=0
% 
%   In the above equation, C contains N+1 elements whose sum is
%   automatically normalized to unity. U is the normalized path difference
%   as defined by Norton and Beer. Little improvement is achieved through
%   the use of more than 5 coefficients.
%
%   Several filter parameters were defined by Norton and Beer. Those
%   parameters can be used by defining C as one of the following character
%   strings:
%
%   FILTER STRENGTH  	C0      C1          C2          C3      C4      
%   'none'              1       0           0           0       0       
%   'weak'              0.5480  -0.0833     0.5353      0       0       
%   'medium'            0.26    -0.154838	0.894838    0       0       
%   'strong'            0.09    0           0.5875      0       0.3225 
%
%   By default, the 'weak' filter parameters are used.
%
%   NORTONBEER(W,C,SFLAG) generates the W-point Norton-Beer window using
%   SFLAG window sampling. SFLAG may be either 'symmetric' or 'periodic'.
%   By default, a symmetric window is returned.
%
%  % Example:
%  %   Creates 64-point Norton Beer window and display the result in WVTool
%
%   L = 64;
%   wvtool(nortonbeer(L))
%
%   See also blackman, hann, hamming, window.
%

%
%   REF: R. H. Norton and R. Beer, "New apodizing functions for Fourier
%   spectrometry," J. Opt. Soc. Am. 66, 259-264 (1976).
%

%
%   Jered R Wells
%   2013/04/24
%   jered [dot] wells [at] gmail [dot] com
%
%   v1.1
%
%   UPDATES
%       2013/04/24 - jrw - v1.1
%       Updated documentation. Made output a column vector. Corrected
%       coefficient normalization.
%

%% INPUT CHECK
narginchk(1,3);
nargoutchk(0,1);
fname = 'nortonbeer';

% Checked required inputs
validateattributes(W,{'numeric'},{'scalar','nonnegative','integer'},fname,'W',1);

% Set defaults for optional inputs
optargs = {'weak','symmetric'};

numvarargs = length(varargin);
for ii = 1:numvarargs; if isempty(varargin{ii}); varargin{ii} = optargs{ii}; end; end

% Now put these defaults into the valuesToUse cell array, 
% and overwrite the ones specified in varargin.
optargs(1:numvarargs) = varargin;
% or ...
% [optargs{1:numvarargs}] = varargin{:};

% Place optional args in memorable variable names
[C,SFLAG] = optargs{:};

% Check optional inputs
if ischar(C)
    switch lower(C)
        case {'none','no'}
            C = [1,0,0,0,0];
        case {'weak'}
            C = [0.5480,-0.0833,0.5353,0,0];
        case {'med','medium'}
            C = [0.26,-0.154838,0.894838,0,0];
        case {'strong'}
            C = [0.09,0,0.5875,0,0.3225];
        otherwise
            error('MATLAB:nbfilter:C','Invalid option for C')
    end
else
	inputcheck(C,{'numeric'},{'nonempty','vector'},fname,'C',2); 
    C = C./sum(C);
end
inputcheck(SFLAG,{'char'},{},fname,'SFLAG',3);

%% PROCESS

switch lower(SFLAG)
    case 'symmetric'
        ctr = (W-1)/2;
    case 'periodic'
        ctr = ceil((W-1)/2);
    otherwise
        error('MATLAB:nbfilter:SFLAG','Invalid SFLAG option')
end
U = abs((0:W-1)-ctr)./ctr;

filt = zeros(size(U));
for ii = 0:numel(C)-1
    filt = filt + C(ii+1).*(1-U.^2).^ii;
end

% Assemble the VARARGOUT cell array
varargout = {filt(:)};

end % MAIN

Contact us