You are on page 1of 51

1

Time Frequency Analysis and Wavelet


Transforms

Office 723 , TEL 33669652


E-mail: jjding@ntu.edu.tw

http://djj.ee.ntu.edu.tw/TFW.htm

: 15 scores
11.8 ( )
( ) 0.8

Homework: 60 scores
5 times, 3
60%
40~95% 8
E-mail

Term paper 25 scores


3
Term paper 25 scores

(1)
(10 ( ) 11 12

abstract, conclusion,
references sections subsections References
, IEEE )

(Ctrl-C , Ctrl-V) 60%

(2) Tutorial
18 (
tutorial (2/3)N + 13 N tutorial )

Word
3
4
(3)
40
11 26 ( 11 ) 11
12

2
2

(4) Wikipedia
2
80

Wikipedia 1 7 ( )
(2 )

Wikipedia 1 21
5
16

9/22, 11/17, HW2


9/29, 11/24, HW3
10/6, 12/1,
10/13, 12/8, HW3, HW4
HW1
12/15, Oral
10/20,
12/22,
10/27, HW1
12/29, HW4,
11/3, HW2
1/5, HW5
11/10,

1/19, HW5 term paper


6

(1) Introduction
(2) Short-Time Fourier Transform
(3) Gabor Transform
(4) Implementation of Time-Frequency Analysis
(5) Wigner Distribution Function
(6) Cohens Class Time-Frequency Distribution
(7) S Transforms, Gabor-Wigner Transforms, Matching Pursuit, and Other Time
Frequency Analysis Methods
(8) Movement in the Time-Frequency Plane and Fractional Fourier Transforms
(9) Filter Design by Time-Frequency Analysis
(10) Modulation, Multiplexing, Sampling, and Other Applications
()
7

(11) Hilbert Huang Transform


(12) Continuous Wavelet Transforms
(13) Continuous Wavelet Transform with Discrete Coefficients
(14) Discrete Wavelet Transform
(15) Applications of the Wavelet Transform
8

(1) ( )
(2) S. Qian and D. Chen, Joint Time-Frequency Analysis: Methods and
Applications, Prentice-Hall, 1996.
(3) L. Cohen, Time-Frequency Analysis, Prentice-Hall, New York, 1995.
(4) K. Grochenig, Foundations of Time-Frequency Analysis, Birkhauser,
Boston, 2001.
(5) L. Debnath, Wavelet Transforms and Time-Frequency Signal Analysis,
Birkhuser, Boston, 2001.
(6) S. Mallat, A Wavelet Tour of Signal Processing: The Sparse Way,
Academic Press, 3rd ed., 2009.
(7) Others
9
Matlab Program
Download:
http://comm.ntu.edu.tw/matlab/request.php

Matlab 7 2010. . (
)
Matlab 2011.
Matlab 2007.
-Matlab 2005.

3~5
10
Tutorial ( )
*
(1) Chirplet Transform
(2) Basis Pursuit for Compressive Sensing
(3) Sparse Coding with Compressive Sensing
(4) Time-frequency Analysis for Underwater Acoustics
(5) Time-frequency Analysis for Electroencephalography (EEG) Signals
(6) Time-frequency Analysis for Signal Communication
(7) Polynomial Wigner-Ville Distributions
(8) Hilbert Huang Transforms for Denoising
(9) Stationary Wavelet Transform
(10) Shannon Wavelet
(11) Wavelet for Video Compression
(12) Noiselet
11
I. Introduction
Fourier transform (FT)

X f x t e j 2 f t dt Time-Domain Frequency Domain

t varies from ~

Laplace Transform X s x t e s t dt

Cosine Transform, Sine Transform, Z Transform.

Some things make these operations not practical:


(1) Only the case where t0 t t1 is interested.
(2) Not all the signals are suitable for analyzing in the frequency
domain.

It is hard to observe the variation of spectrum with time by these


operations
12

Example 1: x(t) = cos(440 t) when t < 0.5,


x(t) = cos(660 t) when 0.5 t < 1,
x(t) = cos(524 t) when t 1

The Fourier transform of x(t)

0.2

0.15

0.1

0.05

0
-0.05

-0.1

-0.15

-0.2

-0.25
-400 -300 -200 -100 0 100 200 300 400

Frequency
13
(A) Finite-Supporting Fourier Transform
t0 B
X f x t e j 2 f t dt
t0 B

(B) Short-Time Fourier Transform (STFT)



X t , f w t x e j 2 f d

w(t): window function mask function


STFT windowed Fourier transform
time-dependent Fourier transform
[Ref] L. Cohen, Time-Frequency Analysis, Prentice-Hall, New York, 1995.
[Ref] A. V. Oppenheim and R. W. Schafer, Discrete-Time Signal Processing,
London: Prentice-Hall, 3rd ed., 2010.
14

w(t) = 1 for |t| B,


w(t) = 0 otherwise -B B t-axis
Short-time Fourier transform
tB
X t, f x e j 2 f d
tB

w t exp t 2
t-axis
0

exp(- t2) Gaussian function Gabor


function

Short-Time Fourier Transform Gabor Transform


15
(C) Gabor Transform
t
j 2 f ( )
Gx t , f e ( t ) 2
e 2
x d

( t )2 t
1 j ( )
Gx t , e 2
e 2
x d
2

S. Qian and D. Chen, Joint Time-Frequency Analysis: Methods and


Applications,
Prentice Hall, N.J., 1996.
R. L. Allen and D. W. Mills, Signal Analysis: Time, Frequency, Scale, and
Structure, Wiley- Interscience.
Common Features for short-time Fourier transforms and Gabor transforms
(1) The instantaneous frequency can be observed
(2) Without Cross Term
(3) Poor clarity
16
Example: x(t) = cos(440 t) when t < 0.5,
x(t) = cos(660 t) when 0.5 t < 1,
x(t) = cos(524 t) when t 1
The Gabor transform of x(t) ( = 200)
400

300

200
f -axis (Hertz)

100

-100

-200

-300

-400
0 0.5 1 1.5
taxis (Second)

Gray level X(t, f) amplitude


17
Instantaneous Frequency
N
If x(t ) ak exp( j
k (t )) around t0
k 1
then the instantaneous frequency of x(t) at t0 are
1 '(t0 ) 2 '(t0 ) 3 '(t0 ) '(t )
, , ,L , N 0 ( frequency )
2 2 2 2

1 '(t0 ),2 '(t0 ),3 '(t0 ),L , N '(t0 ) ( angular frequency )

If the order of k (t ) > 1, then instantaneous frequency varies with time


18

Frequency Modulation

Music

Speech

Others (Animal voice, Doppler effect, seismic waves, radar system, optics,
rectangular function)

In fact, in addition to sinusoid-like functions, the instantaneous frequencies


of other functions will inevitably vary with time.
19
Sinusoid Function

Chirp function
2
exp j ( 2t 1t 0 )
2
Instantaneous frequency = t 1
2

acoustics, wireless communication, radar system, optics


(F1 = 900Hz, F2 = 1200Hz) , (F1 = 300Hz, F2 = 2300Hz)
F1 , F2 - F1

Higher order exponential function


20
Example 2
(1) x(t ) 0.5cos 6400 t 600 t 2 t [0, 3]

(2) x(t ) 0.5cos 600 t 3 2700 t 2 5050 t t [0, 3]


21
Fourier transform

x(t ) 0.5cos 6400 t 600 t 2 x (t ) 0.5cos 600 t 3 2700 t 2 5050 t

0.015 0.05

0.01

0.005

0 0

-0.005

-0.01

-0.015 -0.05
0 1000 2000 3000 4000 0 1000 2000 3000 4000

f (Hz) f (Hz)
22
(1) (2)
x(t ) 0.5cos 6400 t 600 t 2 x(t ) 0.5cos 600 t 3 2700 t 2 5050 t
4000 4000
3000 3000

2000 2000
frequency (Hz)

frequency (Hz)
1000 1000

0 0

-1000 -1000

-2000 -2000

-3000 -3000

-4000 -4000
0 1 2 3 0 1 2 3
time (Sec) time (Sec)
23
Example 3

left: x1(t) = 1 for |t| 6, x1(t) = 0 otherwise, right: x2(t) = cos(6t 0.05t2)

Gabor transform
-10 -10

-5 -5

0 0
-axis

5 5

10 10
-10 -5 0 5 10 -10 -5 0 5 10
t -axis
24
Example 4

Data source: http://oalib.hlsresearch.com/Whales/index.html

2500

2000

1500
frequency (Hz)

1000

500

0
5 10 15 20 25
time (sec)
25
Why Time-Frequency Analysis is Important?

Many digital signal processing applications are related to the spectrum or


the bandwidth of a signal.

If the spectrum and the bandwidth can be determined adaptive, the


performance can be improved.

modulation, signal identification,


multiplexing, acoustics,
filter design, system modeling,
data compression, radar system analysis
signal analysis, sampling
26
Example: Generalization for sampling theory

The supporting of x(t) is t1 t t1 + T, x(t) 0 otherwise f


The supporting of X( f ) 0 is -B f B, X( f ) 0 otherwise
B
t1 t1+T
t
t 1/F , F =2B, B:
N -B

N = T/t TF

27
Q1 Scaling
Hint:
1 f
g t
FT G

Q2: How to use time-frequency analysis to reduce the number of sampling


points?

Time-frequency analysis is an efficient tool for adaptive signal processing.


28
square spectrogram
(1) Short-time Fourier
Asymmetric STFT
transform (STFT) improve
S transform
(rec-STFT, Gabor,
) combine Gabor-Wigner Transform
windowed WDF
improve
(2) Wigner distribution
function (WDF) improve Cohens Class Distribution
(Choi-Williams, Cone-Shape, Page,
Levin, Kirkwood, Born-Jordan, )
improve
Pseudo L-Wigner Distribution
Haar and Daubechies
(3) Wavelet transform Coiflet, Morlet
Directional Wavelet Transform
(4) Time-Variant Matching Pursuit
Basis Expansion
Prolate Spheroidal Wave Function

(5) Hilbert-Huang Transform ( Fourier transform )


29
Continuous Wavelet Transform
forward wavelet transform:
1 t a
X a, b x t dt
b
b
(t): mother wavelet, a: location, b: scaling,
inverse wavelet transform:

x t X a, b a ,b t
a b
a,b(t) is dual orthogonal to (t).

output

Fourier transform X(f), f: frequency

time-frequency analysis X(t, f), t: time, f: frequency

wavelet transform X(a, b), a: time, b: scaling


30

1 t a
(1)
a1 ,b1

t dt 1 when a1 = a and b1 = b,
b b
1 t a

a1 ,b1
t dt 0 otherwise
b b
(2) (t) has a finite time interval

Two parameters, a: , b:

adaptive signal analysis


b
31
Wavelet
Mexican hat wavelet, Haar Wavelet, Daubechies wavelet, triangular
wavelet,
Mexican hat wavelet a and b

1 2 t e 1 t a
5/ 4
t 2 2 t 2

3 b b

a = 2, b = 1 a = 6, b = 1 a = 10, b = 1
2 2 2

1 1 1

0 0 0

0 5 10 0 5 10 0 5 10
a = 6, b = 0.5 a = 6, b = 2 a = 6, b = 3
2 2 2

1 1 1

0 0 0

0 5 10 0 5 10 0 5 10
32
Discrete Wavelet Transform (DWT)
The discrete wavelet transform is very different from the continuous wavelet
transform. It is simpler and more useful than the continuous one.
L-points
lowpass filter down sampling
xL[n] x[n]
g[n] 2 x1,L[n
N-points L-points ]
x[n] highpass filter down sampling
xH[n]
2 x1,H[n] x[n]
h[n]

xL n x n k g k x1, L n x 2n k g k
k k

xH n x n k h k x1, H n x 2n k h k
k k
33
x1, L n x 2n k g k x1, H n x 2n k h k
k k

2-point Haar wavelet


g[n] = 1/2 for n = 1, 0 h[0] = 1/2, h[1] = 1/2,
g[n] = 0 otherwise h[n] = 0 otherwise

g[n] h[n]

-3 -2 -1 0 1 2 3 n -3 -2 -1 0 1 2 3 n
-
then
x 2n x 2n 1 x 2n x 2n 1
x1, L n x1, H n
2 2
( ) ( )
34
Discrete wavelet transform
(discrete Haar wavelet, discrete Daubechies wavelet, B-spline DWT,
symlet, coilet, ..)

wavelet, g[n] h[n] 2


g[n] lowpass filter
h[n] highpass filter
35
2-D

L-points g[m] 2 x1,L[m, n]


along m m , n
g[n] 2 v1,L[m, n]
M N along n h[m] 2 x1,H1[m, n]
x[m, n] along m m , n
L-points
g[m] 2 x [m, n]
1,H2
h[n] 2 v1,H[m, n]
along m m , n
along n
h[m] 2 x1,H3[m, n]
along m m , n
n

m x[m, n]
36

100


200

Pepper.bmp
300

400

500
100 200 300 400 500

x1,L[m, n] x1,H2[m, n]
100

2-D DWT
200

300

400
x1,H1[m, n] x1,H3[m, n]
500
100 200 300 400 500
3 2-D 37
DWT

50

100

150

200

250

300

350

400

450

500
50 100 150 200 250 300 350 400 450 500
38

(JPEG 2000)

edge detection
corner detection
filter design
pattern recognition
music signal processing
economical data
temperature analysis
feature extraction
biomedical signal processing
39
(by Matlab)

A.

*.wav

wavread (2015 audioread)

[x, fs] = wavread('C:\WINDOWS\Media\ringin.wav');


ringin.wav x fs: sampling frequency
size(x) = 9981 1 fs = 11025

: ?


40

time = [0:length(x)-1]/fs; % x wavread


plot(time, x)
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

*.wav 1 +1
41

[x, fs]=wavread('C:\WINDOWS\Media\ringin.wav', [4001 5000]);
% 4001 5000
[x, fs, nbits] = wavread('C:\WINDOWS\Media\ringin.wav');
nbits: x(n) bit
bit : bit : 21 bit : 22 ..
n bit : 2nbits +1 x 2nbits 1

nbits = 8 x 128
42
Stereo ( )
[x, fs]=wavread('C:\WINDOWS\Media\notify.wav');
size(x) = 29823 2 fs = 22050
0.2
x( : ,1) notify.wav

0.1

-0.1

-0.2
0 0.2 0.4 0.6 0.8 1 1.2 t
0.2
x( : ,2) notify.wav

0.1

-0.1

-0.2
0 0.2 0.4 0.6 0.8 1 1.2 t
43
B.

X = fft(x); plot(abs(X)*dt); % dt = 1/fs

0.04

abs(X)*dt
ringin.wav
0.03

0.02

0.01

0
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
m

fft
(1) Using normalized frequency F: F = m / N.
(2) Using frequency f, f = F fs = m (fs / N).
44
0.04
abs(X)*dt
ringin.wav
0.03

0.02

0.01

0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
F
0.04

abs(X)*dt
ringin.wav
0.03

0.02

0.01

0
0 1000 2000 3000 4000 5000
f
45
C.

(1) wavplay(x): x 11025Hz


( = 1/11025 = 9.07 10-5
)
(2) sound(x): x 8192Hz
(3) wavplay(x, fs) sound(x, fs): x fs Hz
Note: (1)~(3) x 1 column ( 2 columns) x
1 +1
(4) soundsc(x, fs): x -1 +1
46
D. Matlab *.wav wavwrite

wavwrite(x, fs, waveFile)


x *.wav fs Hz
x 1 column ( 2 columns) x 1
+1
fs fs 8000Hz

(2015 audiowrite)
47
E. Matlab

( notebooks )

Sec = 3;
Fs = 8000;
recorder = audiorecorder(Fs, 16, 1);
recordblocking(recorder, Sec);
audioarray = getaudiodata(recorder);

sampling frequency 8000 Hz


audioarray column vector (
column vectors)
48

()
wavplay(audioarray, Fs); %
t = [0:length(audioarray)-1]./Fs;
plot (t, audioarray); %
xlabel('sec','FontSize',16);
wavwrite(audioarray, Fs, test.wav) % *.wav

49

recorder = audiorecorder(Fs, nb, nch); ( )


Fs: sampling frequency,
nb: using nb bits to record each data
nch: number of channels (1 or 2)

recordblocking(recorder, Sec); ( )
recorder: the parameters obtained by the command audiorecorder
Sec: the time length for recording

audioarray = getaudiodata(recorder);
( audioarray column vector
audioarray column vectors)


50
F MP3

mp3read.m, mp3write.m

http://www.mathworks.com/matlabcentral/fileexchange/13852-mp3read-
and-mp3write
Dan Ellis

mp3read.m : mp3
mp3write.m : mp3

*.wav ( ) *.mp3 MPEG-2


Audio Layer III
51

%% Write an MP3 file by Matlab

fs=8000; % sampling frequency


t = [1:fs*3]/3;
filename = test;
Nbit=32; % number of bits per sample
x= 0.2*cos(2*pi*(500*t+300*(t-1.5).^3));
mp3write(x, fs, Nbit, filename); % make an MP3 file test.mp3

%% Read an MP3 file by Matlab

[x1, fs1]=mp3read('phase33.mp3');
x2=x1(577:end); % delete the head
sound(x2, fs1)

You might also like