Professional Documents
Culture Documents
Abstract: - This paper presents MATLAB programs for generating the coefficients of the lowpass analysis
filter corresponding to orthonormal wavelet analyses. One of the programs generates the famous Daubechies
maxflat wavelets, and a second generates the Daubechies complex symmetric orthonormal wavelets. The
remaining two programs generate the space of all orthonormal wavelets in terms of parameterizations whereby
the space of wavelets of a given length 2N is generated by N parameters. This software should prove useful
where it is desired to perform an optimization to obtain the best wavelet for a given application.
2 parameters [0,), and calculating the remaining and for the odd numbered filter coefficients {h2i +1} :
parameter from the regularity constraint.
The parameterization can be extended to produce h2( ik++11) =
1
1 + k k
(
h2(ik+)1 k h2(ik ) + k h2(ik+)2 + k k h2(ik+)1+ 2 ( 1) k .)
filters with complex-valued coefficients, simply by
The recurrence is started with the Haar length-2
allowing the i to be complex. However, the
wavelet, h0(1) = h1(1) = 12 ; then regularity of the
parameterization of Section 2.2 turns out to be better
suited to this purpose. wavelet is preserved throughout the iterative process
2.2 Generating Wavelets Using Real-Valued irrespective of the choice of i . An advantage over
Parameters the parameterization in Section 2.1 is that this
The parameterization used in this section is based parameterization does not exhibit the redundancies
upon the work of Pollen [5] and the subsequent that occurred in Section 2.1 due to the angular nature
results of Lina [3,4]. As in Section 2.1, let the of the i parameters. Here, the space of all
coefficients of the scaling filter be denoted by {hi }, orthonormal regular wavelets with real coefficients
is simply produced by allowing the i to range over
with z-transform H ( z ) = h z i
i
. Then the
i all real values.
parameterization of the space of all regular perfect- Furthermore, restricting all i to be pure
reconstruction two-channel filter banks of length
imaginary generates the space of all symmetric
2M+2 in terms of M parameters { 0 , 1 ,..., M 1 } is complex orthonormal wavelets. These wavelets are
produced as described below. important because they are the only orthonormal
Define 2-by-2 matrices G i (z ) by function h=nuorthgen(nus)
% Generates all orthonormal regular wavelets.
u i ( z ) wi ( z ) % nus is an array of parameters satisfying:
% nus all real => space of all real
Gi ( z) = , i=0,,M-1. % orthonormal regular wavelets
w ( z) u ( z) % nus all imaginary => space of all
i i % symmetric complex orthonormal
% regular wavelets
i i
where u i ( z ) = 1 + ( z 1 1) % nus complex => space of all orthonormal
1 + i i % regular wavelets
h0 = 1/sqrt(2);
i h1 = 1/sqrt(2);
and wi ( z ) = ( z 1) . h=[h0 h1] ;
1 + i i stages=length(nus);
for stage=1:stages
Then form G ( z ) = G 0 G1T G 2 G 3T ...G M 2 G MT 1 , nu=nus(stage);
nuc=conj(nu);
where the notation G T represents the conjugate N=length(h)+2;
transpose. Note that conjugate transposition is h=[0 0 conj(h) 0 0];
for i=2:2:N+1
applied to every second matrix in the above product. newh(i)= h(i)-nu*h(i-1)+nu*h(i+1)+ ...
Finally, the filter coefficients in this nu*nuc*h(i+2);
parametrization are obtained as i1=i+1;
newh(i1)=h(i1)-nuc*h(i1-1)+ ...
z
H ( z) = 1
(1 1)G ( z 2 ) . end
nuc*h(i1+1)+ nu*nuc*h(i1-2);
1
2
h=newh(2:N+1)/(1+nu*nuc);
Because, just as in Section 2.1, the filter is end
produced by a successive product of matrices, it is Figure 3. MATLAB function for generating orthonormal
wavelets using parameterization of Section 2.2.
wavelets that exhibit linear phase. Linear phase is function dau=makedau(N)
% Function to generate coefficients of
highly valuable in many applications because the % Daubechies maxflat orthonormal wavelet
position of details is preserved in the filtered signal. % filter of length N.
An efficient implementation in MATLAB is given %
in Figure 3. if mod(N,2) ~=0
error('N must be even');
end
3 Daubechies Wavelets p=N/2;
b(p)=1;
for i=p-1:-1:1
3.1 Generating Daubechies Maxflat b(i)= b(i+1)*(2*p-i-1)/(4*(p-i));
end
Wavelets r=roots(b)/4;
The Daubechies maxflat wavelet of length 2N is the z1= (1-2*r) + sqrt((1-2*r).^2 -1);
unique length 2N wavelet whose frequency response z2= (1-2*r) - sqrt((1-2*r).^2 -1);
z=[z1;z2];
has both minimum phase and also exhibits N zero zchoose = z( abs(z)<1 ); % for minimum phase
derivatives at = 0 [2]. These wavelets are widely q=poly(zchoose);
used because of their regularity. The wavelet is q=real(q);
%add p zeros at -1
obtained by a spectral factorization of the following flat=1;
halfband frequency response [8]: for i=1:p
N k flat=conv(flat,[1 1]);
1 + cos N 1 N + k 1 1 cos
end
P ( ) = 2 dau= conv(q,flat);
2 k =0 k 2 dau= sqrt(2)*dau/sum(dau);
1 cos Figure 4. MATLAB function for generating Daubechies
Introduce y = ; then y , , and the z- maxflat wavelets.
2
transform variable are related by
1 3.2 Generating Daubechies Symmetric
z+z Complex Wavelets
cos = = 1 2 y . Expressing P( ) in
2 A Daubechies symmetric complex wavelet of length
~
terms of y yields P ( y ) = 2(1 y ) N B N ( y ) , where 2N is a length-2N wavelet whose frequency response
N 1 N + k 1 exhibits N zero derivatives at = 0 and also has
k
B N ( y ) = y is the binomial series linear phase [3]. Linear phase is a highly desirable
k =0 k property that cannot be achieved in orthonormal
truncated after N terms. wavelets unless the coefficients are allowed to be
The spectral factorization of P ( ) and the complex. These wavelets are obtained by the
spectral factorization of the same halfband filter as
subsequent determination of the scaling filter
coefficients are performed as follows: in Section 3.1, i.e. :
1. Find the N-1 zeros {y i } of the polynomial
N N 1 k
1 + cos N + k 1 1 cos
P ( ) = 2
2
k
2
BN ( y) . k =0
2. Transform these to the z domain using The coefficients are calculated according to the
same four steps shown in Section 3.1, except that
z i = 1 2 y i (1 2 y i ) 2 1 . Because of the now the roots of the factorization to be retained in
square root, this yields a total of 2N-2 values. step 3 are chosen in order to achieve symmetry
3. Of the 2N-2 values of z i , retain only those N-1 rather than minimum phase. Symmetry is achieved
by ensuring that roots are retained in pairs ( zi , zi1 ).
that have z i < 1 . This choice results in a
(Since more than one solution achieving symmetry
minimum phase filter. can be obtained, we choose also to ensure that
4. Include a further N zeros at z = 1 . The retained zeros within the unit circle are evenly
coefficients of the resultant polynomial are the distributed above and below the real axis.)
taps of the scaling filter for the Daubechies Therefore, step 3 of the process becomes:
maxflat filter of length 2N.
3a. Of the 2N-2 values of z i , retain only those
This procedure is implemented in the MATLAB
program of Figure 4, which generates these 2N 2
that have zi > 1 and positive real
wavelets. 4
part. What this does is to reduce each quadruplet
( zi , zi1 , zi , zi1 ) of roots to a single root
outside the unit circle and having positive 4 Conclusion
imaginary part. We have presented MATLAB implementations of
N 1 two parameterizations of the space of orthonormal
3b. Sort these roots into increasing order of wavelets. In addition to their obvious use in
2 generating wavelets with real coefficients, we have
real part. indicated how these may be used to generate
N 1 symmetric wavelets with complex coefficients. This
3c. Distribute these roots evenly above and
2 software would be useful in an optimization task in
below the real axis, by taking the conjugate of which the best wavelet for a given application is
every second root. sought.
3d. Include the inverse of each root. This results in We also presented MATLAB functions that
a total of N-1 roots. produce the commonly encountered Daubechies
Note that for step 3a to succeed, it is necessary that max-flat wavelets, as well as the symmetric complex
2N 2 Daubechies wavelets.
be an integer, i.e. that N be odd.
4 References:
Consequently, symmetric complex Daubechies [1] A. Cohen, I. Daubechies and J.C. Feauveau,
wavelets exist only for odd N, i.e. filters of length Biorthogonal bases of compactly supported
2N = 2, 6, 10, 14, etc. wavelets, Comm. Pure Appl. Math., vol. 45,
A MATLAB function to generate these wavelets is 1992, pp 485-560.
presented in Figure 5. [2] I. Daubechies, Orthonormal bases of compactly
function dau=makecxdau(N)
% Function to generate coefficients of supported wavelets, Comm. Pure Appl. Math.,
% Daubechies maxflat symmetric complex vol. 41, 1988, pp 909-966.
% orthonormal wavelet filters. [3] J.M. Lina and M. Mayrand, Complex
%
if mod(N,2) ~=0 Daubechies Wavelets, University of Montreal
error('N must be even'); Laboratory of Nuclear Physics Report UdeM-
end PHYSNUM-ANS-15, December 1993.
p=N/2;
b(p)=1; [4] J.M. Lina and M. Mayrand, Parameterizations
for i=p-1:-1:1 for Daubechies Wavelets, Physical Review E,
b(i)= b(i+1)*(2*p-i-1)/(4*(p-i)); Vol. 48, No. 6, 1993, pp. R4160-R4163.
end
r=roots(b)/4;
[5] D. Pollen, SU1(2,F(z,1/z)) for F a subfield of C,
z1= (1-2*r) + sqrt((1-2*r).^2 -1); Journal of the American Mathematical Society,
z2= (1-2*r) - sqrt((1-2*r).^2 -1); Vol.3, No.3, 1990, pp. 611-624.
z=[z1;z2];
% Keep one of every quadruplet z, 1/z, zbar,
[6] B.G. Sherlock and D.M. Monro, On the Space of
% 1/zbar: Orthonormal Wavelets, IEEE Transactions on
zchoose = z( abs(z)>1 & imag(z) >0); Signal Processing, Vol. 46, No. 6, 1998, pp.
% sort in order of increasing real part: 1716-1720.
[junk,index]= sort(real(zchoose));
zchoose = zchoose(index); [7] B.G. Sherlock and D.M. Monro, Optimized
% Distribute evenly above / below real axis: Wavelets for Fingerprint Compression, IEEE
zchoose(1:2:length(zchoose))=... International Conference on Acoustics, Speech and
conj(zchoose(1:2:length(zchoose)));
zchoose = [zchoose; 1./zchoose];
Signal Processing (ICASSP-96), Atlanta, Georgia,
if(length(zchoose) ~= length(z)/2) May 1996, Vol. III, pp. 1447-1450
disp('No symmetric solutions for this N:') [8] G. Strang and T. Nguyen, Wavelets and Filter
error('N must be of form 2*(odd number)') Banks, Wellesley-Cambridge Press, 1996.
end
q=poly(zchoose); [9] P.P. Vaidyanathan, Multirate Systems and Filter
% add p zeros at -1 Banks, Prentice Hall, 1992.
flat=1;
for i=1:p
flat=conv(flat,[1 1]);
end
dau= conv(q,flat);
dau= sqrt(2)*dau/sum(dau);
Figure 5. MATLAB function for generating complex
symmetric Daubechies maxflat wavelets.