CP467 IP & PR - Wilfrid Laurier University

Download Report

Transcript CP467 IP & PR - Wilfrid Laurier University

Lecture 12
Introduction to Wavelets
1.
2.
3.
4.
Multiresolution analysis. The concepts of wavelets
The theory of wavelet
Continuous/discrete wavelet transformation
Fast wavelet transformation
View Image by multiple resolutions
Image Pyramids
• An image pyramid is a collection of decreasing
resolution images arranged in the shape of a pyramid
• For example, the ith level has resolution 2i  2i
• The total number of pixels of a pyramid is
1
1
1
4 2
N (1 

 ... 
) N
1
2
P
(4)
(4)
(4)
3
2
A system to generate Pyramids
• A scheme for pyramid system
For j = p to 1, where 2p = N
Output: approximation, prediction residual images
End
• Two pyramids are produced
Image Pyramids
Approximation and interpolation filters
• Approximation filter
– In spatial domain such as neighborhood averaging
• Interpolation filter
– nearest neighbor, bilinear, and bicubic
• Upsampling
 f (n / 2),
f 2 ( n )  
0

n  even
else
• Downsampling
f 2 (n)  f (2n)
• Example of approximation”
and residual pryamids
Subband coding
• Another multiresolution analysis
– Decompose an image into a set of bandlimitted components,
called subbands.
– The subbands can be reassembled to reconstruct the original
image without error
• The decomposition is done by digital filters
– Example of subband in DSP
Example of digital filter in DSP
• Using operations: unit delay, multipliers, and adders
• The filter coefficients are determined by the impulse response
fˆ (n ) 

 h(k ) (n  k )  h(n)
k 
• If there are K coefficients, it is called finite impulse response filter (FIR)
Functionally related filters
Filter banks
• Two FIR filter h0(n) and h1(n) are used to decomposed f(n) into half
length sequences flp(n) and fhp(n)
– Called the subbands that represent the input.
– flp(n) is called approximation of f(n)
– fhp(n) is the detail part of f(n)
• Synthesis bank filters g0(n) and g1(n) combine flp(n) and fhp(n) to
produce fˆ (n)
• The goal is to select
h0(n), h1(n), g0(n) and g1(n)
such that f^(n) = f(n)
– perfect reconstruction filters
Example of perfect reconstruction filters
• Cross-modulated filters
g 0 (n)  (1) n h1 (n)
g1 (n)  (1) n 1 h0 (n)
hi (2n  k ), g j (k )   (i  j ) (n), i, j {0,1}
f1 , f 2   f1 (n) f 2 (n)
n
• Orthonormality
g1 (n)  ( 1)n g0 ( Keven  1  n)
hi (n)  ( 1)n gi ( Keven  1  n), i {0,1}
When g0(n) is determined, others are determined
Example of perfect reconstruction filters
2-D four band filter bank
• First apply the filters to one dimension (vertically)
• Second apply filters to the second dimension (horizontally
Example of image subband decomposition
The Haar transformation
• Haar transformation can be expressed as
where F is N X N image, H is N X N matrix
T  HFH T
• The Haar matrix can be derived as follows:
The ith row of H is hi ( z ), z  0 / N ,1/ N ,...,( N  1) / N
where hi ( z ) is defined by
h0 ( z )  h00 ( z ) 
1
, z  [0,1]
N
 2 p / 2 , ( q  1) / 2 p  z  ( q  0.5) / 2 p
1  p/2
p
p
hk ( z )  h pq ( z ) 
, z  [0,1]
 2 , ( q  0.5) / 2  z  q / 2
N 
else
 0,
• Examples


1 1 1 
1 
H2 
1 1 , H 4 
2
4



1
1
1
1
2
0
 2
0
1 
1 1 

0

2  2 
1
Multiresolution expansion
• Multiresolution anlaysis (MRA)
• A scaling function is used to create a series of
approximation of a image, each near pair of near images
differing in a factor of 2 in resolution
• Additional functions, called wavelets are then used to
encode the difference in the information between
adjacent approximation
•
•
•
•
f ( x)    kk ( x)
Expansion:
k
Expansion coefficients:  k
Basis functions: {k ( x)}
Function space V  Span{k ( x)}
k
Multiresolution expansion
• Dual function set {k ( x)} such that
 k  k ( x), f ( x)   k ( x) f ( x)dx
• { ( x)} is orthonormal basis if
k
•
0
 j ( x), k ( x)   jk  
1
Then
jk
jk
k  k ( x), f ( x)
0
1
 j ( x), k ( x)   jk  
• {k ( x)} is biorthonormal basis if
• Over complement if they form a frame in which
A || f ( x) ||2   |  j ( x), k ( x) |2  B || f ( x) ||2
k
Tied frame
1
A  B, f ( x)   | k ( x), f ( x) k ( x)
A k
jk
jk
Scaling functions
• A set of functions { j ,k ( x)} where
 j ,k ( x)  2 j / 2  (2 j x  k )
j , k  Z ,  ( x)  L ( R)
2
•
Example
1 0  x  1
 ( x)  
0 otherwise
f ( x)  0.51,0 ( x)  1,1 ( x)  0.251,4 ( x)
V0  V1
V j  Span{ j ,k ( x)}
k
Scaling functions
• MRA requirement 1: scale function is orthogonal to is its
integer translate
• MRA requirement 2: subspaces at low scale are nested
within those of high scale.
•
V  ...  V  V  ...  V

0
1

• MRA requirement 3: The only function that are common
to all is f(x)=0
• MRA requirement 4: Any function can be represented
with arbitrary precision
V  {L2 ( R)}
 j ,k ( x)    n j 1,n ( x)
n
 j ,k ( x)   h (n)2( j 1) / 2  (2 j 1 x  n)
n
 ( x)   h (n) 2 (2 x  n)
n
Wavelet functions
• Given scaling function  ( x) that meets MRA
requirements
• Wavelets { j ,k ( x)} , where  j ,k ( x)  2 j / 2 (2 j x  k )
W j  Span{ j ,k ( x)}
k
f ( x)    k j ,k ( x)
k
V j 1  V j  W j
 j ,k ( x), j ,l ( x)  0
Wavelet functions
L2 ( R)  V0  W0  W1  ...
L2 ( R)  V1  W1  W2  ...
L2 ( R)  V j0  W j0  W j0 1  ...
 ( x)   h (n) 2 (2 x  n)
n
h (n)  (1)n h (1  n)
• Example
 1, 0  x  0.5

 ( x)  1, 0.5  x  1
 0,
else

f ( x)  f a ( x)  f d ( x)
f a ( x) 
3 2
2
0,0 ( x) 
0,2 ( x)
4
8
f d ( x) 
 2
2
 0,0 ( x)   0,2 ( x)
4
8
Wavelet series expansions
L2 ( R)  V j0 Wj0 W j0 1  ...

f ( x)   c j0 (k ) j0 ( x)    d j (k ) j ,k ( x)
k
•
j  j0 k
is an arbitrary starting scale
c j (k ) is called approximation and/or scaling coefficients;
j0
0
c j0 (k )  f ( x),  j0 ,k ( x)   f ( x) j0 ,k ( x)dx
d j (k ) is called detail and/or wavelet coefficients
d j (k )  f ( x), j ,k ( x)   f ( x) j ,k ( x)dx
Example
 1, 0  x  0.5

 ( x)  1, 0.5  x  1
 0,
else

1 0  x  1
 ( x)  
0 otherwise
 j ,k ( x)  2 j / 2  (2 j x  k )
 j ,k ( x)  2 j / 2 (2 j x  k )
 x2 , 0  x  1
y  f ( x)  
else
 0,
 j ,k ( x)  2 j / 2 (2 j x  k )
j0  0
1
1
0
0
c0 (0)   x 20,0 ( x)dx   x 2 dx 
1
d 0 (0)   x  0,0 ( x) dx  
2
0.5
x dx  
2
0
0
1
0.25
d1 (0)   x 2 1,0 ( x) dx  
0
0
1
3
1
0.5
x 2 dx  
x 2 2dx  
0.5
0.25
1
4
x 2 2dx  
2
32
3 2
0
0.5
0.75
32

1
2
3 2
 1
 
y  0,0 ( x)     1,0 ( x)    
 1,0 ( x) 
 1,1 ( x)   ...
3
4
32
32

 

1
d1 (1)   x  1,1 ( x)dx  
2
0.75
x
2
2dx  
1
x 2 2dx  
Continuous Wavelet Transformation (CWT)
• Similar to FT, CWT can be defined as

W ( s, t )   f ( x) s ,t ( x)dx

1
xt
 s ,t ( x )   (
)
s
s
• Then the inverse wavelet transformation is
1
f ( x) 
C


0
 s ,t ( x )
 W (s, t ) s 2 dtds

| (u ) |2
C  
dx

u

Discrete Wavelet Transformation
• Given f (n)  f ( x0  nx), n  0,1, 2,..., M 1
• Forward DWT transformation
1
W ( j0 , k ) 
f (n) j0 ,k (n)

M n
1
W ( j , k ) 
f (n) j ,k (n), j  j0

M n
• The inverse DWT transformation
1
f ( n) 
M
1
W
(
j
,
k
)

(
n
)

n  0 j0 ,k
M

 W ( j, k )
j  j0 k
j ,k
( n)
Example
• Given
f (0)  1, f (1)  4, f (2)  3, f (3)  0, M  4, J  2, j0  0
1
1
f
(
n
)

(
n
)

[1 1  4 1  3 1  0 1]  1

0,0
2 n
2
1
W (0, 0)  [1 1  4 1  3 ( 1)  0 ( 1)]  4
2
1
W (1, 0)  [1 2  4 (  2)  3 0  0 0]  1.5 2
2
1
W (1,1)  [1 1  4 0  3 2  0 (  2)]  1.5 2
2
1
f (n)  [W (0, 0)0,0 (n)  W (0, 0) 0,0 (n)  W (1, 0) 1,0 (n)  W (1,1) 1,1 (n)]
2
W (0, 0) 
Fast Wavelet Transformation
• Similar to FFT, FWT is developed
 ( x)   h (n) 2 (2 x  n)
n
 (2 j x  k )   h (m  2k ) 2 (2 j 1 x  m)
m
 ( x)   h (n) 2 (2 x  n)
n
 (2 j x  k )   h (m  2k ) 2 (2 j 1 x  m)
m
W ( j , k )   h (m  2k )W ( j  1, m)  h (n) W ( j  1, n) |n  2 k ,k 0
m
W ( j , k )   h (m  2k )W ( j  1, m)  h (n) W ( j  1, n) |n  2 k ,k 0
m
Can be implemented by FWT analysis bank
W ( j, k )  h (n) W ( j  1, n) |n2 k ,k 0
W ( j, k )  h (n) W ( j  1, n) |n2 k ,k 0
Fast Wavelet Transformation (FWT)
Example
 1

h (n)   2
 0

n  0,1
othereise
 1
 2

 1
h (n)  
 2
 0


n0
n 1
otherwise
Inverse FWT
• Similar to Inverse FFT
Example
Wavelet Transforms in 2-D
• 2-D scaling function
 ( x, y )   ( x) ( y )
• Three 2-D wavelets
 ( x, y )   ( x) ( y )
 H ( x, y )   ( x) ( y )
 ( x, y )   ( x) ( y )
V
 D ( x, y )   ( x) ( y )
2-D WT
• Scaling function and wavelets
 j ,m,n ( x, y )  2 j / 2  (2 j x  m, 2 j y  n)
 ij ,m,m ( x, y )  2 j / 2 i (2 j x  m, 2 j y  n), i {H ,V , D}
• Forward WT
M 1 N 1
1
W ( j0 , m, n) 
MN
1
W ( j , m, n) 
MN
i
• Inverse WT
f ( x, y ) 
1
MN

1
MN
  f ( x, y)
x 0 y 0
j0 , m , n
M 1 N 1
  f ( x, y)
x 0 y 0
i
j0 , m , n
( x, y )
( x, y ), i {H ,V , D}
 W ( j , m, n)
0
m
j0 , m , n
( x, y ) 
n

i
i
W
(
j
,
m
,
n
)

  
j0 , m , n ( x, y )
i{ H ,V , D} j  j0
m
n