In this section we will examine properties of the filters, scale and wavelet using the two-scale equation:
The fact that the scale function and the low pass filter satisfy this equation has some remarkable consequences.
Keep in mind that we are making a number of assumptions:
The two-scale equation shows that coordinates of
with
respect to the basis
are the filter coefficients
.
If we delay
by n then the coordinates of
are the
filter coefficients delayed by
(i.e.
. This can be easily
seen by substituting
for
in the two-scale equation.
The same is true of the wavelet function and the filter
.
Since the integer time shifts of the wavelet and the scale are orthogonal we have:
These equations are called the double shift orthogonality relations of the filters. They lead to a number of other properties of the filters.
For a proof of this equation see Proof 3 in Appendix A, page 247 of the textbook (WWT).
For a proof of this fact see Proof 10 in Appendix A, page 250 of the textbook (WWT).
Example
To illustrate these equations we can use the m-file dshift.m as follows:
[h0 h1] = wfilters('db3','r')
h0 =
0.3327 0.8069 0.4599 -0.1350 -0.0854 0.0352
h1 =
0.0352 0.0854 -0.1350 -0.4599 0.8069 -0.3327
sum(h0)
ans =
1.4142
sum(h1)
ans =
-2.9981e-12
h0even = dyaddown(h0,1)
h0even =
0.3327 0.4599 -0.0854
h0odd = dyaddown(h0,0)
h0odd =
0.8069 -0.1350 0.0352
sum(h0even)
ans =
0.7071
sum(h0odd)
ans =
0.7071
h1even = dyaddown(h1,1)
h1even =
0.0352 -0.1350 0.8069
h1odd = dyaddown(h1,0)
h1odd =
0.0854 -0.4599 -0.3327
sum(h1even)
ans =
0.7071
sum(h1odd)
ans =
-0.7071
p0 = conv(h0,wrev(h0))
p0 =
Columns 1 through 7
0.0117 -0.0000 -0.0977 0.0000 0.5859 1.0000 0.5859
Columns 8 through 11
0.0000 -0.0977 -0.0000 0.0117
p1 = conv(h1, wrev(h1))
p1 =
Columns 1 through 7
-0.0117 -0.0000 0.0977 0.0000 -0.5859 1.0000 -0.5859
Columns 8 through 11
0.0000 0.0977 -0.0000 -0.0117
>> diary off
In the frequency domain we have a number of properties.
This is proven by taking the Fourier Transform of both sides of the two-scale equation.
Note that this is a very unique equation because
is the
continuous time transform while
is the discrete time Transform.
To understand this equation we can define the filter
Notice that the double shift orthognality shows that
and
for
. That is,
is a
centered, symmetric half-band filter.
In the frequency domain we have
so that
we are trying to show that
.
The filter with frequency response
is the filter
with alternating signs:
. We therefore have:
Frequency Domain Time Domain
P(f) <----> [ . . . p(-3) 0 p(-1) 1 p(1) 0 p(3) 0 p(5) . . . ]
P(f+1/2) <----> [ . . .-p(-3) 0 -p(-1) 1 -p(1) 0 -p(3) 0 -p(5) . . . ]
sum <----> [ . . . 0 0 0 2 0 0 0 0 0
It follows that
.
Example
To illustrate these equations we can use the m-file dshiftf.m as follows:
% File: dshiftf.m
% Illustrates the frequency domain properties of the filters
%echo on;
%diary dshiftf.diary;
[h0 h1] = wfilters('db3','r')
p0 = conv(h0,wrev(h0));
% alternate signs
ind = 1:2:length(p0);
p0shift = p0;
p0shift(ind) = -p0shift(ind);
[H0,W] = freqz(h0);
[H1,W] = freqz(h1);
[P0,W] = freqz(p0);
[P0shift,W] = freqz(p0shift);
subplot(2,2,1);
plot(W/(2*pi), abs(H0));
title('Low Pass Filter Response H_{0}(f)');
xlabel('Frequency');
axis([0 0.5 0 2.1]);
subplot(2,2,2);
plot(W/(2*pi), abs(H1));
title('High Pass Filter Response H_{1}(f)');
xlabel('Frequency');
axis([0 0.5 0 2.1]);
subplot(2,2,3);
plot(W/(2*pi), abs(P0),W/(2*pi),abs(P0shift));
title('P_{0}(f) and P_{0}(f + 1/2)');
xlabel('Frequency');
axis([0 0.5 0 2.1]);
subplot(2,2,4);
plot(W/(2*pi), abs(P0)+abs(P0shift));
title('P_{0}(f) + P_{0}(f + 1/2)');
xlabel('Frequency');
axis([0 0.5 0 2.1]);
%orient landscape;
%print -depsc 'dshiftf.eps';
The support of a function
is the range of values of
where
the function is non-zero.
The two-scale equation imposes a restriction on the support of the scale function.
Assume that the low pass filter
is causal with length
. Then we
will show that the support of
is the interval
.
The two-scale equation becomes:
If we assume that
has support on an interval
then
the first term in the sum,
, has support
and the last term in the sum,
, has support
.
It follows that the largest possible support for the sum is
. That is
and
. Hence
and
.
The two-scale equation can be used to approximate the scale function using
the low pass filter
. We can think of the two-scale equation as
an iteration. That is, starting with an approximation
we
produce a sequence of approximations
by considering the
two-scale equation as an update formula:
As a numerical algorithm we start with estimates
of
on the integer values
. Then, the first iteration produces
an approximation to
at the half-integer points
via:
The next iteration produces estimates of
at the quarter-integer
points
and so on.
If we carry out this algorithm for M steps then we get approximate values
of
at points
where
ranges
over
. That is, the times range from
up to
.
Once we have an estimate for the scale function we can produce an estimate
of the wavelet function from it and the high pass filter
.
This algorithm can be implemented directly in Matlab but it is somewhat slow to carry out as Matlab is an interprted language.
This slowness is a general Matlab problem for any algorithm involving many nested for loops. If we can formulate our algorithm to use built in vector operations rather than for loops it will be much faster. There is a vector version of the algorithm which we can derive as follows.
We know that the subspaces
,
,
, ...,
give a
finer and finer decomposition of functions using the basis functions
.
That is, any function
in
can be written in terms of the
basis in
and also in terms of the basis in
:
We know that the coefficients
are obtained by passing the
coefficients
through
levels of the synthesis bank.
Now recall that the coordinates of the scale function,
, in
are exaclty the low pass filter coefficents,
, and the coordinates
of the wavelet,
, in V1 are exactly the high pass filter coefficients,
.
Hence we should upsample and low pass filter these two sets of coefficents
times to get their coefficients in
.
At this point we must ``estimate''
. We know that
So we can estimate this function by a box of height
extending
for
units of time. We might as well center this box in the
interval
, where
= length of the filter
.
Define
. Then
Substituting this for
we get that
The m-file ocascade.m carries out this algorithm.
function [phi,psi,x]=ocascade(h0,iter) %[phi,psi,x]=ocascade(h0,iter) % %carrys out the cascade algorithm %iter is the number of iterations used. if nargin == 1 iter = 8; end N=length(h0)-1; % compute the high pass filter (alternating flip) h1 = fliplr(h0); h1(2:2:(N+1)) = - h1(2:2:(N+1)); % do the first iteration phi = h0; psi = h1; % now the rest of the iterations for i=(2:iter) % upsample top = 2*length(phi)-1; temp = phi; phi = zeros(1,top); phi(1:2:top) = temp; temp = psi; psi = zeros(1,top); psi(1:2:top) = temp; % filter phi = conv(h0,phi); psi = conv(h0,psi); end % scale the answers and pad with zeros on both ends to account for the offset % note that the last x sample is exactly N - 1/2^iter. offset = (N-1)/2; pad = zeros(1,offset); %pad=[]; phi=2^(iter/2)*[pad phi pad]; psi=2^(iter/2)*[pad psi pad]; % compute the grid x nf=length(phi); % same for all %x = linspace(0, (nf-1)/2^iter,nf); x = (0:(nf-1))/2^iter;
Example
The m-file ocascadedemo.m demonstrates the use the this m-file.