You are on page 1of 109

Wavelets (Chapter 7)

CS474/674 Prof. Bebis

STFT (revisited)
Time/Frequency localization depends on window size.
Once you choose a particular window size, it will be the same
for all frequencies.
Many signals require a more flexible approach - vary the
window size to determine more accurately either time or
frequency.

The Wavelet Transform


Overcomes the preset resolution problem of the STFT by
using a variable length window:
Use narrower windows at high frequencies for better time
resolution.
Use wider windows at low frequencies for better frequency
resolution.

The Wavelet Transform (contd)

Wide windows do not provide good localization


at high frequencies.

The Wavelet Transform (contd)

Use narrower windows at high frequencies.

The Wavelet Transform (contd)

Narrow windows do not provide good localization


at low frequencies.

The Wavelet Transform (contd)

Use wider windows at low frequencies.

What are Wavelets?


Wavelets are functions that wave above and below the
x-axis, have (1) varying frequency, (2) limited duration,
and (3) an average value of zero.
This is in contrast to sinusoids, used by FT, which have
infinite energy.
Sinusoid

Wavelet

What are Wavelets? (contd)


Like sines and cosines in FT, wavelets are used as basis
functions k(t) in representing other functions f(t):

f (t ) ak k (t )
k

Span of k(t): vector space S containing all functions f(t)


that can be represented by k(t).

What are Wavelets? (contd)


There are many different wavelets:
Haar

Morlet

Daubechies

What are Wavelets? (contd)

jk (t )

(dyadic/octave grid)

What are Wavelets? (contd)


jk (t ) 2

2 t k

j/2

scale/frequency
localization

time localization

Continuous Wavelet Transform (CWT)


translation parameter,
measure of time

scale parameter
(measure of frequency)

1
C ( , s )
s
Continuous Wavelet Transform
of signal f(t)

normalization
constant

t
f t
dt
s

Forward
CWT:

Mother wavelet
(window)

Scale = 1/j = 1/Frequency

CWT: Main Steps


1. Take a wavelet and compare it to a section at the start
of the original signal.
2. Calculate a number, C, that represents how closely
correlated the wavelet is with this section of the
signal. The higher C is, the more the similarity.

CWT: Main Steps (contd)


3. Shift the wavelet to the right and repeat steps 1 and 2 until
you've covered the whole signal.

CWT: Main Steps (contd)


4. Scale the wavelet and repeat steps 1 through 3.

5. Repeat steps 1 through 4 for all scales.

Coefficients of CTW Transform


Wavelet analysis produces a time-scale view of the input
signal or image.
1
t
C ( , s )
f t
dt

s t
s

Continuous Wavelet Transform (contd)


Inverse CWT:

1
f (t )
s

t
s C ( , s) ( s )d ds
double integral!

FT vs WT
weighted by F(u)

weighted by C(,s)

Properties of Wavelets
Simultaneous localization in time and scale
- The location of the wavelet allows to explicitly represent

the location of events in time.


- The shape of the wavelet allows to represent different
detail or resolution.

Properties of Wavelets (contd)


Sparsity: for functions typically found in practice,
many of the coefficients in a wavelet representation
are either zero or very small.
1
f (t )
s

t
s C ( , s) ( s )d ds

Linear-time complexity: many wavelet


transformations can be accomplished in O(N) time.

Properties of Wavelets (contd)


Adaptability: wavelets can be adapted to represent a
wide variety of functions (e.g., functions with
discontinuities, functions defined on bounded domains
etc.).
Well suited to problems involving images, open or closed
curves, and surfaces of just about any variety.
Can represent functions with discontinuities or corners more
efficiently (i.e., some have sharp corners themselves).

Discrete Wavelet Transform (DWT)


a jk f (t ) *jk (t )

(forward DWT)

f (t ) a jk jk (t ) (inverse DWT)
k
j
j/2
j

(
t
)

2
t k
jk
where

DFT vs DWT
FT expansion:

one parameter basis


or

f (t ) a l l (t )
l

two parameter basis

WT expansion

f (t ) a jk jk (t )
k

Multiresolution Representation using

jk

(t )

f (t )

fine
details

wider, large translations


f (t )
k

a
j

jk (t )

jk

j
coarse
details

Multiresolution Representation using

jk

(t )

f (t )

fine
details

f (t )
k

a
j

jk (t )

jk

j
coarse
details

Multiresolution Representation using

jk

(t )

f (t )

narrower, small translations


f (t )
k

a
j

jk (t )

jk

fine
details

j
coarse
details

Multiresolution Representation using

jk

(t )

high resolution

f (t )

(more details)

f1 (t )
f2 (t )

low resolution

fs (t )

(less details)

f (t )
k

a
j

jk (t )

jk

Prediction Residual Pyramid (revisited)


In the absence of quantization errors, the approximation
pyramid can be reconstructed from the prediction residual
pyramid.
Prediction residual pyramid can be represented more
efficiently.

(with sub-sampling)

Efficient Representation Using Details


details D3

details D2

details D1

L0
(no sub-sampling)

Efficient Representation Using Details (contd)

L0 D1 D2 D3
in general: L0 D1 D2 D3DJ

representation:

(decomposition
or analysis)

A wavelet representation of a function consists of


(1)a coarse overall approximation
(2)detail coefficients that influence the function at various scales.

Reconstruction (synthesis)
H3=L2+D3

H2=L1+D2
details D3

details D2

H1=L0+D1

details D1
L0
(no sub-sampling)

Example - Haar Wavelets


Suppose we are given a 1D "image" with a resolution
of 4 pixels:

[9 7 3 5]
The Haar wavelet transform is the following:

L 0 D 1 D2 D3

(with sub-sampling)

Example - Haar Wavelets (contd)


Start by averaging the pixels together (pairwise) to get
a new lower resolution image:

To recover the original four pixels from the two


averaged pixels, store some detail coefficients.
1

Example - Haar Wavelets (contd)


Repeating this process on the averages gives the full
decomposition:

Example - Haar Wavelets (contd)


The Harr decomposition of the original four-pixel
image is:

We can reconstruct the original image to a resolution


by adding or subtracting the detail coefficients from
the lower-resolution versions.
2

1 -1

Example - Haar Wavelets (contd)


Note small magnitude
detail coefficients!

Dj
Dj-1

L0

D1

How to
compute Di ?

Multiresolution Conditions
If a set of functions can be represented by a weighted
sum of (2jt - k), then a larger set, including the
original, can be represented by a weighted sum of
(2j+1t - k):
high
resolution

scale/frequency
localization

low
resolution
time localization

Multiresolution Conditions (contd)


If a set of functions can be represented by a weighted
sum of (2jt - k), then a larger set, including the
original, can be represented by a weighted sum of
(2j+1t - k):
Vj: span of (2jt - k):

f j (t ) ak jk (t )
k

Vj+1: span of (2j+1t - k): f j 1 (t ) bk ( j 1) k (t )


k

V j V j 1

Nested Spaces Vj
Vj : space spanned by (2jt - k)

Basis functions:
(t - k)

V0

(2t - k)

f(t) Vj

f (t )
k

jk (t )

jk

V1

(2jt - k)

Vj

Multiresolution conditions nested spanned spaces: V j V j 1


i.e., if f(t) V j then f(t) V j+1

How to compute Di ? (contd)


f(t) Vj

f (t )
k

jk (t )

jk

IDEA: define a set of basis


functions that span the
differences between Vj

Orthogonal Complement Wj
Let Wj be the orthogonal complement of Vj in Vj+1
Vj+1 = Vj + Wj

How to compute Di ? (contd)


If f(t) Vj+1, then f(t) can be represented using basis
functions (t) fromVj+1:

f (t ) ck (2 j 1 t k )

Vj+1

Alternatively, f(t) can be represented using two basis functions,


(t) from Vj and (t) from Wj:
Vj+1 = Vj + Wj

f (t ) ck (2 j t k ) d jk (2 j t k )
k

How to compute Di ? (contd)


Think of Wj as a means to represent the parts of a function
in Vj+1 that cannot be represented in Vj

f (t ) ck (2 j 1 t k )
k

f (t ) ck (2 j t k ) d jk (2 j t k )
k

Vj,

Wj

differences
between
Vj and Vj+1

How to compute Di ? (contd)

Vj+1 = Vj + Wj using recursion on Vj:


Vj+1 = Vj-1+Wj-1+Wj = = V0 + W0 + W1 + W2 + + Wj
if f(t) Vj+1 , then:
f (t ) ck (t k ) d jk (2 j t k )
k

V0
basis functions

W0, W1, W2,


basis functions

Summary: wavelet expansion (Section 7.2)


Wavelet decompositions involve a pair of waveforms
(mother wavelets):
encode low
resolution info

(t)

(t)

encode details or
high resolution info

The two shapes are translated and scaled to produce


wavelets (wavelet basis) at different locations and on
different scales.

(t-k)

(2jt-k)

Summary: wavelet expansion (contd)


f(t) is written as a linear combination of (t-k) and

(2jt-k) :

f (t ) ck (t k ) d jk (2 t k )
j

scaling function

wavelet function

1D Haar Wavelets
Haar scaling and wavelet functions:

(t)

computes average

(t)

computes details

1D Haar Wavelets (contd)


Think of a one-pixel image as a function that is constant
over [0,1)
Example:

We will denote by V0 the space of all such functions.

1D Haar Wavelets (contd)


Think of a two-pixel image as a function having two
constant pieces over the intervals [0, 1/2) and [1/2,1)
Examples:

We will denote by V1 the space of all such functions.


Note that

V0 V1
=

1D Haar Wavelets (contd)


V j represents all the 2j-pixel images
Functions having constant pieces over 2j equal-sized
intervals on [0,1).
j
width: 1/2

Examples:

Note that V j 1 V j

Vj

Vj

1D Haar Wavelets (contd)


V0, V1, ..., V j are nested
i.e.,

V j V j 1

VJ fine details

V2
V1 coarse details

1D Haar Wavelets (contd)


Mother scaling function:
1
0

Lets define a basis for V j :

i ( x ) ji ( x )
note alternative notation:

1D Haar Wavelets (contd)

1D Haar Wavelets (contd)


Suppose Wj is the orthogonal complement of Vj in Vj+1

1D Haar Wavelets (contd)


Mother wavelet function:
1
-1
0

1/2

Note that (x) . (x) = 0 (i.e., orthogonal)


1

1
0

-1

=0
0

1/2

1D Haar Wavelets (contd)


Mother wavelet function:
1
-1
0

Lets define a basis ji for Wj :

note alternative notation:


i ( x ) ji ( x )

1D Haar Wavelets (contd)

basis for V 1 :

basis W 1 :
j=1

Note
that inner
product
is zero!

1D Haar Wavelets (contd)


Basis functions ji of W j
Basis functions ji of V j

form a basis in V j+1

1D Haar Wavelets (contd)

V3 = V2 + W2

1D Haar Wavelets (contd)

V2 = V1 + W1

1D Haar Wavelets (contd)


V1 = V0 + W0

1D Haar Wavelets- Summary


(t)

(t)

Example - Haar basis (revisited)

Decomposition of f(x)
f(x)=
0,2(x)
V2

1,2(x)
2,2(x)
3,2(x)

Decomposition of f(x) (contd)


0,1(x)
V1and W1

1,1(x)

V2=V1+W1

0,1(x)
1,1(x)

Example - Haar basis (revisited)

Decomposition of f(x) (contd)

Decomposition of f(x) (contd)


0,0(x)

V0 ,W0 and W1

0,0(x)

V2=V1+W1=V0+W0+W1

0,1(x)
1,1(x)

Example - Haar basis (revisited)

Example

Example (contd)

Filter banks (analysis)


The lower resolution coefficients can be calculated
from the higher resolution coefficients by a treestructured algorithm (filter bank).
(2t - k)
f1 (t ) a1k 1k (t )
k

Example:
a1k (j=1)

(t - k)
f0 (t ) a0 k 0 k (t )
k

a0k (j=0)

Filter banks (analysis) (contd)


The lower resolution coefficients can be calculated
from the higher resolution coefficients by a treestructured algorithm (filter bank).

Subband
encoding!

h0(-n) is a lowpass filter and h1(-n) is a highpass filter

Example - Haar basis (revisited)


[9 7 3 5]
low-pass,
down-sampling

(9+7)/2

high-pass,
down-sampling

(3+5)/2

(9-7)/2 (3-5)/2

V1 basis functions

Filter banks (analysis) (contd)

Example - Haar basis (revisited)


[9 7 3 5]

low-pass,
down-sampling

high-pass,
down-sampling

V1 basis functions

(8+4)/2

(8-4)/2

Convention for illustrating


1D Haar wavelet decomposition
x

x
average
detail

re-arrange:
V1 basis functions
re-arrange:

Convention for illustrating


1D Haar wavelet decomposition (contd)

average
detail

Orthogonality and normalization


The Haar basis forms an orthogonal basis
It can become orthonormal through the following
normalization:
i j ( x) 1/ 2 j (2 j x i) 2 j / 2 (2 j x i)
i j ( x) 1/ 2 j (2 j x i ) 2 j / 2 (2 j x i )
since

ji ( x) 2 j , ji ( x) 2 j

Examples of lowpass/highpass
analysis filters

Haar

h0
h1

h0
Daubechies
h1

Filter banks (synthesis)


The higher resolution coefficients can be calculated from
the lower resolution coefficients using a similar structure.

Filter banks (synthesis) (contd)

Examples of lowpass/highpass
synthesis filters
Haar (same as
for analysis):

g0
g1
g0

Daubechies
+

g1

2D Haar Wavelet Transform


The 2D Haar wavelet decomposition can be computed
using 1D Haar wavelet decompositions (i.e., 2D Haar
wavelet basis is separable).
Two decompositions
Standard decomposition
Non-standard decomposition

The two decompositions correspond to a different set


of 2D basis functions.

Standard Haar wavelet decomposition


Steps
(1) Compute 1D Haar wavelet decomposition of each row of
the original pixel values.
(2) Compute 1D Haar wavelet decomposition of each
column of the row-transformed pixels.

Standard Haar wavelet decomposition


(contd)
average
detail

(1) row-wise Haar decomposition:

re-arrange terms

xxx
xxx

xxx

...

x
x
.
x

Standard Haar wavelet decomposition


(contd)
average
detail

(1) row-wise Haar decomposition:

row-transformed result

Standard Haar wavelet decomposition


(contd)
average
detail

(2) column-wise Haar decomposition:


row-transformed result

column-transformed result

Example

row-transformed result

re-arrange terms

Example (contd)

column-transformed result

2D Haar basis for standard decomposition


To construct the standard 2D Haar wavelet basis, consider
all possible outer products of 1D basis functions.
0,0(x)

Example:
V2=V0+W0+W1

0,0(x)
0,1(x)
1,1(x)

2D Haar basis for standard decomposition


To construct the standard 2D Haar wavelet basis, consider
all possible outer products of 1D basis functions.

00(x), 00(x)

00(x), 00(x)

i j ( x) ji ( x)

01(x), 00(x)

i j ( x) ji ( x)

2D Haar basis of standard decomposition

V2

i j ( x) ji ( x)
i j ( x) ji ( x)

Non-standard Haar wavelet decomposition


Alternates between operations on rows and columns.
(1) Perform one level decomposition in each row (i.e., one
step of horizontal pairwise averaging and differencing).
(2) Perform one level decomposition in each column from
step 1 (i.e., one step of vertical pairwise averaging and
differencing).
(3) Repeat the process on the quadrant containing averages
only (i.e., in both directions).

Non-standard Haar wavelet decomposition


(contd)
one level, horizontal
Haar decomposition:
xxx
xxx

xxx

...

x
x
.
x

one level, vertical


Haar decomposition:

Note: averaging/differencing
of detail coefficients shown as

Non-standard Haar wavelet decomposition


(contd)
re-arrange terms

one level, horizontal


Haar decomposition
on green quadrant

one level, vertical


Haar decomposition
on green quadrant

Example

re-arrange terms

Example (contd)

2D Haar basis for non-standard decomposition


Defined through 2D scaling and wavelet functions:

( x, y ) ( x) ( y )

000 ( x, y ) ( x, y )

( x, y ) ( x) ( y )
( x, y ) ( x) ( y )
( x, y ) ( x) ( y )

kfj ( x, y ) 2 j (2 j x k , 2 j y f )
kfj ( x, y ) 2 j (2 j x k , 2 j y f )
kfj ( x, y ) 2 j (2 j x k , 2 j y f )

2D Haar basis for non-standard decomposition


(contd)
Three sets of detail coefficients (i.e., subband encoding)

000 ( x, y ) ( x, y ) LL: average LL


( x, y ) 2 (2 x k , 2 y f )
j
kf

kfj ( x, y ) 2 j (2 j x k , 2 j y f )

Detail coefficients
LH: intensity variations along
columns (horizontal edges)

HL: intensity variations along

kfj ( x, y ) 2 j (2 j x k , 2 j y f ) HH:

rows (vertical edges)


intensity variations along
diagonals

2D Haar basis for non-standard decomposition


(contd)

i j ( x) ji ( x)

V2

i j ( x) ji ( x)

Forward/Inverse DWT
(using textbooks notation)
LL
i=H,V,D

H LH
V HL
D HH

2D DWT using filter banks (analysis)

LH

HH

H LH
V HL
D HH

LL

HL

Illustrating 2D wavelet decomposition


LH
LL

LH

HL

HH

LL

HH

HL

The wavelet transform can be applied again on the lowpass-lowpass


version of the image, yielding seven subimages.

2D IDWT using filter banks (synthesis)


H LH
V HL
D HH

Wavelets Applications
Noise filtering
Image compression
Fingerprint compression

Image fusion
Recognition
G. Bebis, A. Gyaourova, S. Singh, and I. Pavlidis, "Face Recognition by
Fusing Thermal Infrared and Visible Imagery", Image and Vision
Computing, vol. 24, no. 7, pp. 727-742, 2006.

Image matching and retrieval


Charles E. Jacobs Adam Finkelstein David H. Salesin, "Fast
Multiresolution Image Querying", SIGRAPH, 1995.

Image Querying Using Wavelets

query by content or
query by example
Typically, the K best
matches are reported.

Fast Multiresolution Image Querying

painted

low resolution

queries

target

You might also like