% HIGHBOOSTFILTER - Constructs a high-boost Butterworth filter.
%
% usage: f = highboostfilter(sze, cutoff, n, boost)
% 
% where: sze    is a two element vector specifying the size of filter 
%               to construct [rows cols].
%        cutoff is the cutoff frequency of the filter 0 - 0.5.
%        n      is the order of the filter, the higher n is the sharper
%               the transition is. (n must be an integer >= 1).
%        boost  is the ratio that high frequency values are boosted
%               relative to the low frequency values.  If boost is less
%               than one then a 'lowboost' filter is generated
%
%
% The frequency origin of the returned filter is at the corners.
%
% See also: LOWPASSFILTER, HIGHPASSFILTER, BANDPASSFILTER
%

% Peter Kovesi  
% School of Computer Science & Software Engineering
% The University of Western Australia
% pk @ csse uwa edu au
% http://www.csse.uwa.edu.au/~pk
%
% October 1999
% November 2001 modified so that filter is specified in terms of high to
%               low boost rather than a zero frequency offset.


function f = highboostfilter(sze, cutoff, n, boost)
        
    if cutoff < 0 | cutoff > 0.5
	error('cutoff frequency must be between 0 and 0.5');
    end
    
    if rem(n,1) ~= 0 | n < 1
	error('n must be an integer >= 1');
    end

    if boost >= 1     % high-boost filter
	f = (1-1/boost)*highpassfilter(sze, cutoff, n) + 1/boost;
    else              % low-boost filter
	f = (1-boost)*lowpassfilter(sze, cutoff, n) + boost;
    end
