<< Chapter < Page | Chapter >> Page > |
function hn = daub(N2)
% hn = daub(N2)% Function to compute the Daubechies scaling coefficients from
% her development in the paper, "Orthonormal bases of compactly% supported wavelets", CPAM, Nov. 1988 page 977, or in her book
% "Ten Lectures on Wavelets", SIAM, 1992 pages 168, 216.% The polynomial R in the reference is set to zero and the
% minimum phase factorization is used.% Not accruate for N>20. Check results for long h(n).
% Input: N2 = N/2, where N is the length of the filter.% Output: hn = h(n) length-N min phase scaling fn coefficients
% by rag 10/10/88, csb 3/23/93a = 1; p = 1; q = 1; % Initialization of variables
hn = [1 1]; % Initialize factors of zeros at -1
for j = 1:N2-1,hn = conv(hn,[1,1]); % Generate polynomial for zeros at -1a = -a*0.25*(j+N2-1)/j; % Generate the binomial coeff. of L
p = conv(p,[1,-2,1]); % Generate variable values for L
q = [0 q 0]+ a*p; % Combine terms for L
end;q = sort(roots(q)); % Factor L
hn = conv(hn,real(poly(q(1:N2-1)))); % Combine zeros at -1 and Lhn = hn*sqrt(2)/(sum(hn)); % Normalize
function h = h246(a,b)
% h = h246(a,b) generates orthogonal scaling function% coefficients h(n) for lengths 2, 4, and 6 using
% Resnikoff's parameterization with angles a andb.
% csb. 4/4/93if a==b, h = [1,1]/sqrt(2); % Length-2elseif b==0
h0 = (1 - cos(a) + sin(a))/2; % Length-4h1 = (1 + cos(a) + sin(a))/2;
h2 = (1 + cos(a) - sin(a))/2;h3 = (1 - cos(a) - sin(a))/2;
h = [h0 h1 h2 h3]/sqrt(2);
else % Length-6h0 = ((1+cos(a)+sin(a))*(1-cos(b)-sin(b))+2*sin(b)*cos(a))/4;
h1 = ((1-cos(a)+sin(a))*(1+cos(b)-sin(b))-2*sin(b)*cos(a))/4;h2 = (1+cos(a-b)+sin(a-b))/2;
h3 = (1+cos(a-b)-sin(a-b))/2;h4 = (1-h0-h2);
h5 = (1-h1-h3);h = [h0 h1 h2 h3 h4 h5]/sqrt(2);end
function [a,b] = ab(h)% [a,b] = ab(h) calculates the parameters a and b from the% scaling function coefficient vector h for orthogonal
% systems of length 2, 4, or 6 only. csb. 5/19/93.%
h = h*2/sum(h); x=0; % normalizationif length(h)==2, h = [0 0 h 0 0]; x=2; end;if length(h)==4, h = [0 h 0]; x=4; end;a = atan2((2*(h(1)^2+h(2)^2-1)+h(3)+h(4)),(2*h(2)*(h(3)-1)-2*h(1)*(h(4)-1)));
b = a - atan2((h(3)-h(4)),(h(3)+h(4)-1));if x==2, a = 1; b = 1; end;
if x==4, b = 0; end;
function y = upsample(x)
% y = upsample(x) inserts zeros between each term in the row vector x.% for example: [1 0 2 0 3 0] = upsample([1 2 3]). csb 3/1/93.
L = length(x);y(:) = [x;zeros(1,L)]; y = y.';y = y(1:2*L-1);
function y = upsam(x,S)
% y = upsam(x,S) inserts S-1 zeros between each term in the row vector x.% for example: [1 0 2 0 3 0] = upsample([1 2 3]). csb 3/1/93.
L = length(x);y(:) = [x;zeros(S-1,L)]; y = y.';y = y(1:S*L-1);
function y = dnsample(x)
% y = dnsample(x) samples x by removing the even terms in x.% for example: [1 3] = dnsample([1 2 3 4]). csb 3/1/93.
L = length(x);y = x(1:2:L);
Notification Switch
Would you like to follow the 'Wavelets and wavelet transforms' conversation and receive update notifications?