You are on page 1of 62

1

Advanced signal processing





Dr. Mohamad KAHLIL
Islamic University of Lebanon
2
Chapter 4: Time frequency and
wavelet analysis
Definition
Time frequency
Shift time fourier transform
Winer-ville representations and others
Wavelet transform
Scalogram
Continuous wavelet transform
Discrete wavelet transform: details and approximations
applications
3
The Story of Wavelets
Theory and Engineering Applications
Time frequency representation
Instantaneous frequency and group delay
Short time Fourier transform Analysis
Short time Fourier transform Synthesis
Discrete time STFT

4
Signal processing
Signal Processing
Time-domain techniques
Freq.-domain techniques
Filters
Fourier T.
Non/Stationary Signals
Stationary Signals
TF domain techniques
WAVELET
TRANSFORMS
STFT
CWT
DWT MRA
2-D DWT SWT
Applications
Denoising
Compression
Signal Analysis
Disc. Detection
BME / NDE
Other
5
FT At Work
) 5 2 cos( ) (
1
t t x = t
) 25 2 cos( ) (
2
t t x = t
) 50 2 cos( ) (
3
t t x = t
6
FT At Work
) (
1
e X
) (
2
e X
) (
3
e X
F
) (
1
t x
F
) (
2
t x
F
) (
3
t x
7
FT At Work
) 50 2 cos(
) 25 2 cos(
) 5 2 cos( ) (
4
t
t
t t x
+
+
=
t
t
t
) (
4
e X
F
) (
4
t x
8
Stationary and Non-stationary
Signals
FT identifies all spectral components present in the signal, however it
does not provide any information regarding the temporal (time)
localization of these components. Why?
Stationary signals consist of spectral components that do not change in
time
all spectral components exist at all times
no need to know any time information
FT works well for stationary signals
However, non-stationary signals consists of time varying spectral
components
How do we find out which spectral component appears when?
FT only provides what spectral components exist , not where in
time they are located.
Need some other ways to determine time localization of spectral
components
9
Stationary and Non-stationary
Signals
Stationary signals spectral characteristics do not change with time





Non-stationary signals have time varying spectra
) 50 2 cos(
) 25 2 cos(
) 5 2 cos( ) (
4
t
t
t t x
+
+
=
t
t
t
] [ ) (
3 2 1 5
x x x t x =

Concatenation
10
Non-stationary Signals
5 Hz 20 Hz 50 Hz
Perfect knowledge of what
frequencies exist, but no
information about where
these frequencies are
located in time
11
FT Shortcomings
Complex exponentials stretch out to infinity in time
They analyze the signal globally, not locally
Hence, FT can only tell what frequencies exist in the
entire signal, but cannot tell, at what time instances
these frequencies occur
In order to obtain time localization of the spectral
components, the signal need to be analyzed locally
HOW ?

12
Short Time Fourier Transform
(STFT)
1. Choose a window function of finite length
2. Put the window on top of the signal at t=0
3. Truncate the signal using this window
4. Compute the FT of the truncated signal, save.
5. Slide the window to the right by a small amount
6. Go to step 3, until window reaches the end of the signal
For each time location where the window is centered, we
obtain a different FT
Hence, each FT provides the spectral information of a
separate time-slice of the signal, providing
simultaneous time and frequency information
13
STFT
14
STFT
| |
}

'
=
'
t
t j
x
dt e t t W t x t STFT
e e
e ) ( ) ( ) , (
STFT of signal x(t):
Computed for each
window centered at t=t

Time
parameter
Frequency
parameter
Signal to
be analyzed
Windowing
function
Windowing function
centered at t=t
FT Kernel
(basis function)
15
0 100 200 300
-1.5
-1
-0.5
0
0.5
1
0 100 200 300
-1.5
-1
-0.5
0
0.5
1
0 100 200 300
-1.5
-1
-0.5
0
0.5
1
0 100 200 300
-1.5
-1
-0.5
0
0.5
1
Windowed
sinusoid allows
FT to be
computed only
through the
support of the
windowing
function
STFT at Work
16
STFT
STFT provides the time information by computing a different FTs for
consecutive time intervals, and then putting them together
Time-Frequency Representation (TFR)
Maps 1-D time domain signals to 2-D time-
frequency signals
Consecutive time intervals of the signal are obtained by truncating the
signal using a sliding windowing function
How to choose the windowing function?
What shape? Rectangular, Gaussian,
Elliptic?
How wide?
Wider window require less time steps low time resolution
Also, window should be narrow enough to make sure that the
portion of the signal falling within the window is stationary
Can we choose an arbitrarily narrow window?
17
Selection of STFT Window
Two extreme cases:
W(t) infinitely long: STFT turns into FT, providing
excellent frequency information (good frequency resolution), but no time
information
W(t) infinitely short:


STFT then gives the time signal back, with a phase factor. Excellent
time information (good time resolution), but no frequency information
Wide analysis window poor time resolution, good frequency resolution
Narrow analysis windowgood time resolution, poor frequency resolution
Once the window is chosen, the resolution is set for both time and frequency.
| |
}

'
=
'
t
t j
x
dt e t t W t x t STFT
e e
e ) ( ) ( ) , (
1 ) ( = t W
) ( ) ( t t W o =
| |
t j
t
t j
x
e t x dt e t t t x t STFT
'

'
=
'
=
'
}
e e e
o e ) ( ) ( ) ( ) , (
18
Heisenberg Principle
t 4
1
> A A f t
Time resolution: How well
two spikes in time can be
separated from each other in
the transform domain

Frequency resolution: How
well two spectral components
can be separated from each
other in the transform domain
Both time and frequency resolutions cannot be arbitrarily high!!!
We cannot precisely know at what time instance a frequency component is
located. We can only know what interval of frequencies are present in which time
intervals
http://engineering.rowan.edu/~polikar/WAVELETS/WTpart2.html
19
STFT
..
..
time
A
m
p
l
i
t
u
d
e

F
r
e
q
u
e
n
c
y

..
..
t
0
t
1
t
k
t
k+1
t
n

20
The Short Time Fourier
Transform
Take FT of segmented consecutive pieces of a signal.
Each FT then provides the spectral content of that time
segment only
Spectral content for different time intervals
Time-frequency representation

| |
}

=
t
t j
x
dt e t W t x STFT
e e
t e t ) ( ) ( ) , (
STFT of signal x(t):
Computed for each
window centered at t=t
(localized spectrum)
Time
parameter
Frequency
parameter
Signal to
be analyzed
Windowing
function
(Analysis window)
Windowing function
centered at t=t
FT Kernel
(basis function)
21
Properties of STFT
Linear
Complex valued
Time invariant
Time shift
Frequency shift
Many other properties of the FT also apply.
22
Alternate Representation
of STFT
e e e e e
e
e
e
t t
d e X e t STFT
df e f f f X e f t STFT
t j t j
x
ft j
f
t f j
x
}
}
I =
I =

)
~
( ) ( )
~
, (
)
~
( ) ( )
~
, (
*
~
) (
2 *
~
2 ) (
STFT : The inverse FT of the windowed spectrum,
with a phase factor
)
~
( ) (
*
f f f X I
23
Filter Interpretation of STFT
{ }
ft j
ft j
f
e t t x f f f X
df e f f f X f f f X F
t
t

2 *
2 * * 1
) ( ) ( )
~
( ) (
)
~
( ) ( )
~
( ) (
- I
I = I
}

X(t) is passed through a bandpass filter with a center frequency of


Note that I(f) itself is a lowpass filter.
f
~
24
Filter Interpretation of STFT
x(t)
ft j
e t
t

2
) (
-
X
ft j
e
t 2
) , (
) (
f t STFT
x

x(t)
) ( t
-
) , (
) (
f t STFT
x

X
ft j
e
t 2
25
Resolution Issues
time
A
m
p
l
i
t
u
d
e

F
r
e
q
u
e
n
c
y

t
k

All signal attributes
located within the local
window interval
around t will appear
at t in the STFT
) (
k
t t
t
n

) (
k
t t
26
Time-Frequency Resolution
Closely related to the choice of analysis window
Narrow window good time resolution
Wide window (narrow band) good frequency
resolution
Two extreme cases:
(T)=o(t) excellent time resolution, no frequency
resolution
(T)=1 excellent freq. resolution (FT), no time
info!!!
How to choose the window length?
Window length defines the time and frequency resolutions
Heisenbergs inequality
Cannot have arbitrarily good time and frequency
resolutions. One must trade one for the other. Their
product is bounded from below.

27
Time-Frequency Resolution
Time
F
r
e
q
u
e
n
c
y

28
Time Frequency Signal
Expansion and STFT Synthesis
}}
=
f
t f j
x
f d d e t g f STFT t x
~

~
2 ) (
~
) ( )
~
, ( ) (
t
t
t t t
Synthesis window
Basis functions
Coefficients
(weights)
Synthesized signal
Each (2D) point on the STFT plane shows how strongly a time
frequency point (t,f) contributes to the signal.
Typically, analysis and synthesis windows are chosen to be
identical.
}
=1 ) ( * ) ( dt t t g
29
300 Hz 200 Hz 100Hz 50Hz
STFT Example
30
2 /
2
) (
at
e t

=
STFT Example
31
a=0.01
STFT Example
32
a=0.001
STFT Example
33
a=0.0001
STFT Example
34
a=0.00001
STFT Example
35
Discrete Time Stft

=
n k
kFt j
x
e nT t g kF nT STFT t x
t 2 ) (
) ( ) , ( ) (
dt e nT t t x kF nT STFT
kFt j
t
x
t

2 * ) (
) ( ) ( ) , (

}
=
36
Time frequency resolution problem
Concepts of scale and translation
The mother of all oscillatory little basis functions
The continuous wavelet transform
Filter interpretation of wavelet transform
Constant Q filters

The Story of Wavelets
Theory and Engineering Applications
37
Time Frequency Resolution
Time frequency resolution problem with STFT
Analysis window dictates both time and frequency
resolutions, once and for all
Narrow window Good time resolution
Narrow band (wide window) Good frequency
resolution
When do we need good time resolution, when do we need
good frequency resolution?

38
Scale & Translation
Translation time shift
f(t) f(a.t) a>0
If 0<a<1 dilation, expansion lower frequency
If a>1 contraction higher frequency
f(t)f(t/a) a>0
If 0<a<1 contraction low scale (high frequency)
If a>1 dilation, expansion large scale (lower
frequency)
Scaling Similar meaning of scale in maps
Large scale: Overall view, long term behavior
Small scale: Detail view, local behavior

39
The Mother of All Oscillatory
Little Basis Functions
The kernel functions used in Wavelet transform are all obtained from
one prototype function, by scaling and translating the prototype
function.
This prototype is called the mother wavelet

a
1
) (
1
) (
,
a
b t
a
t
b a

=
Scale parameter
Translation
parameter
) ( ) (
0 , 1
t t =
Normalization factor to ensure that all
wavelets have the same energy
} } }


= = dt t dt t dt t
b a
2
2
) 0 , 1 (
2
) , (
) ( ) ( ) (
40
Continuous Wavelet Transform
}


-
|
.
|

\
|

= = dt
a
b t
t x
a
b a W b a CWT
x

) (
1
) , ( ) , (
) (
Normalization factor
Mother wavelet
translation
Scaling:
Changes the support of
the wavelet based on
the scale (frequency)

CWT of x(t) at scale
a and translation b
Note: low scale high frequency
41
Computation of CWT
) , 1 (
N
b W
) , 5 (
N
b W
time
A
m
p
l
i
t
u
d
e

b
0

) , 1 (
0
b W
b
N

time
A
m
p
l
i
t
u
d
e

b
0

) , 5 (
0
b W
b
N

time
A
m
p
l
i
t
u
d
e

b
0

) , 10 (
0
b W
b
N

) , 10 (
N
b W
time
A
m
p
l
i
t
u
d
e

b
0

) , 25 (
0
b W
b
N

) , 25 (
N
b W
}


-
|
.
|

\
|

= = dt
a
b t
t x
a
b a W b a CWT
x

) (
1
) , ( ) , (
) (
42
WT at Work
High frequency (small scale)
Low frequency (large scale)
43
Why Wavelet?
We require that the wavelet functions, at a minimum,
satisfy the following:

}


= 0 ) ( dt t
}


< dt t
2
) (
Wave
let
44
The CWT as a Correlation
Recall that in the L
2
space an inner product is defined as



then

Cross correlation:

then
}
-
>= < dt t g t f t g t f ) ( ) ( ) ( ), (
> =< ) ( ), ( ) , (
,
t t x b a W
b a

> =<
=
}
-
) ( ), (
) ( ) ( ) (
t
t t
t y t x
dt t y t x R
xy
) (
) ( ), ( ) , (
,
,
0 ,
b R
b t t x b a W
o a
x
a

=
> =<
45
The CWT as a Correlation
Meaning of life:
W(a,b) is the cross correlation of the signal x(t) with the
mother wavelet at scale a, at the lag of b. If x(t) is similar
to the mother wavelet at this scale and lag, then W(a,b)
will be large.

46
Filtering Interpretation of
Wavelet Transform
Recall that for a given system h[n], y[n]=x[n]*h[n]




Observe that
Interpretation:For any given scale a (frequency ~ 1/a), the
CWT W(a,b) is the output of the filter with the impulse
response to the input x(b), i.e., we have a
continuum of filters, parameterized by the scale factor a.
}
=
=
t t t d t h x
t h t x t y
) ( ) (
) ( * ) ( ) (
) ( * ) ( ) , (
0 ,
b b x b a W
a
=
-

) (
0 ,
b
a

-

47
What do Wavelets Look Like???
Mexican Hat Wavelet
Haar Wavelet
Morlet Wavelet

48
Constant Q Filtering
A special property of the filters defined by the mother
wavelet is that they are so called constant Q filters.

Q Factor:





We observe that the filters defined by the mother wavelet
increase their bandwidth, as the scale is reduced (center
frequency is increased)
bandwidth
f requency center
w (rad/s)
49
Constant Q
f
0
2f
0
4f
0
8f
0
B
2B
4B 8B
B B B B B B
f
0
2f
0
3f
0
4f
0
5f
0
6f
0
S
T
F
T

C
W
T

B
f
Q =
50
Inverse CWT
} }

=
=
a b
b a
dadb t b a W
a
C
t x ) ( ) , (
1 1
) (
,
2

e
e
e
d C
}


+
=
) (
provided that
}


= 0 ) ( dt t
51
Properties of
Continuous Wavelet Transform
Linearity
Translation
Scaling
Wavelet shifting
Wavelet scaling
Linear combination of wavelets
52
Example
53
Example
54
Example
55
Spectrogram &
Scalogram
Spectrogram is the square magnitude of the STFT,






which provides the distribution of the energy of the signal in the time-frequency
plane.
Similarly, scalogram is the square magnitude of the CWT, and provides the
energy distribution of the signal in the time-scale plane:

2
2
0
2
) ( ) (
) ( ) (
) , ( ) , (
}
-
=
= =
t
ft j
x x S
dt e t t t x
f t STFT f t SPEC P
t

2
2
) ( ) (
) (
) (
1
) , ( ) , (
}

=
= =
-
t
x x W
dt
a
b t
t x
a
b a CWT b a SCAL P


56
Energy
It can be shown that





which implies that the energy of the signal is the same whether you are
in the original time domain or the scale-translation space. Compare this
the Parsevals theorem regarding the Fourier transform.

x
E dt t x db da
a
b a CWT
= =
} }}
2
2
2
) (
) , (
57
CWT in
Terms of Frequency
Time-frequency version of the CWT can also be defined, though note that this form
is not standard,




where is the mother wavelet, which itself is a bandpass function centered at t=0 in
time and f=f
0
in frequency. That is f
0
is the center frequency of the mother wavelet.
The original CWT expression can be obtained simply by using the substitution a=f
0
/
f and b= t
In Matlab, you can obtain the pseudo frequency corresponding to any given scale
by where f
s
is the sampling rate and
T
s
is the sampling period.

( ) ( ) dt t
f
f
t x f f f CWT
t
x
}
|
|
.
|

\
|
=
-
t t

0
0
) ( ,
a
T f
f a
f
f
s o
s
o

=

=
58
Discretization of
Time & Scale Parameters
Recall that, if we use orthonormal basis functions as our
mother wavelets, then we can reconstruct the original
signal by


where W(a,b) is the CWT of x(t)
Q: Can we discretize the mother wavelet
a,b
(t) in such a
way that a finite number of such discrete wavelets can still
form an orthonormal basis (which in turnallows us to
reconstruct the original signal)? If yes, how often do we
need to sample the translation and scale parameters to be
able to reconstruct the signal?
A: Yes, but it depends on the choice of the wavelet!
) ( ), , ( ) (
,
t b a W t x
b a
=
59
Dyadic Grid
Note that, we do not have to use a uniform sampling rate
for the translation parameters, since we do not need as high
time sampling rate when the scale is high (low frequency).
Lets consider the following sampling grid:
log a
b
where a is sampled on a log
scale, and b is sampled at a
higher rate when a is small,
that is,




where a
0
and b
0
are constants,
and j,k are integers.

0 0
0
b a k b
a a
j
j
=
=
60
Dyadic Grid
If we use this discretization, we obtain,





A common choice for a
0
and b
0
are a
0
=2 and b
0
= 1, which lend
themselves to dyadic sampling grid


Then, the discret(ized) wavelet transform (DWT) pair can be given as
k j
k j
d
dt t t x b a W
,
,
) ( ) ( ) , (
=
~
}
-

|
.
|

\
|

=
a
b t
a
t
b a

1
) (
,
( )
0 0
2 /
0
0
0 0
0
,
1
) (
kb t a a
a
b ka t
a
t
j j
j
j
j
k j
=
|
|
.
|

\
|

=


DWT

=
=
j k
k j k j
t d
c
t x ) (
1
) (
, ,

Inverse DWT
( ) Z k j k t t
j j
k j
e =

, 2 2 ) (
2 /
,

61
Note that
We have only discretized translation and scale parameters, a and b; time has
not been discretized yet.
Sampling steps of b depend on a. This makes sense, since we do not need as
many samples at high scales (low frequencies)
For small a
0
, say close to 1, and for small b
0
, say close to zero, we obtain a
very fine sampling grid, in which case, the reconstruction formula is very
similar to that of CWT


For dense sampling, we need not place heavy restriction on (t) to be able
reconstruct x(t), whereas sparse sampling puts heavy restrictions on (t).
It turns out that a
0
=2 and b
0
= 1 (dyadic / octave sampling) provides a nice
trade-off. For this selection, many orthonormal basis functions (to be used as
mother wavelets) are available.
} }

=
=
a b
b a
dadb t b a W
a
C
t x ) ( ) , (
1 1
) (
,
2

=
=
j k
k j k j
t d
c
t x ) (
1
) (
, ,

62
Discrete Wavelet Transform
We have computed a discretized version of the CWT,
however, we still cannot implement the given DWT as it
includes a continuous time signal integrated over all times.
We will later see that the dyadic grid selection will allow
us to compute a truly discrete wavelet transform of a given
discrete time signal.

You might also like