function [h,g,rh,rg] = splineFilterBanks(m,n)
% returns the spline filter banks where
% h is the low pass analysis filter,
% g is the high pass analysis filter,
% rh is the low pass reconstruction filter
% and rg is the high pass reconstruction filter.
% The scaling function generated by rh is a B-spline
% of degree m. The wavelet generated by g has thus
% m vanishing moments; the wavelet generated by rg
% has n vanishing moments.
% Reference: Ten lectures on Wavelets, page 271
% A Wavelet Tour of Signal Processing, page 270 (1st US ed.)
if rem(m+n,2)
error('The sum of the number of vanishing moments must be even');
end
rh1 = [0.5 0.5];
rh = rh1;
for i = 2:m
rh = conv(rh,rh1);
end
rh = sqrt(2)*rh;
h1 = [-0.25 0.5 -0.25];
N = (m+n)/2;
tp = zeros(N,m+n-1);
tp(1,N) = 1;
for i = 2:N
tp(i,N-i+1:N+i-1) = conv(tp(i-1,N-i+2:N+i-2),h1);
end
b = binomial(m+n-2);
b = b(N-1:m+n-2,N);
h = b'*tp;
ch = rh1;
for i = 2:n
ch = conv(ch,rh1);
end
h = sqrt(2)*conv(ch,h);
% note that h = fliplr(h);
% make wavelet filters
g = sf2wf(rh);
rg = sf2wf(h);
% adjust signs
if rem(m+1,2) % m is even, h and rh are centered at 0
if rem(m/2,2) % half length of rh is odd
g = -g;
else
rg = -rg;
end
else
if rem((m-1)/2,2) % \tilde{l} in Daubechies book is odd
rg = -rg;
else
g = -g;
end
end