Wavelets

Introduction to Digital Image Processing with MATLAB® Asia Edition
McAndrew‧Wang‧Tseng
Chapter 15:
Wavelets
1
© 2010 Cengage Learning
Engineering. All Rights Reserved.
1
15.1 Waves and Wavelets
• The idea of wavelets is to keep the wave concept, but
drop the periodicity
• We may consider a wavelet to be a little part of a wave,
a wave that is only nonzero in small region
2
Ch15-p.429
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
• Suppose we are given a wavelet
 Dilate it by applying a scaling factor to x: f (2x) would “squash”
the wavelet, and f (x/2) would expand it
 Translate it by adding or subtracting an appropriate value from
x: f (x − 2) would shift the wavelet 2 to the right; f (x + 3) would
shift the wavelet 3 to the left
 Change its height by simply multiplying the function by a
constant
3
Ch15-p.429
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.2
4
Ch15-p.431
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.2
5
Ch15-p.431
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
• 15.1.1 A simple Wavelet Transform
 Wavelet transforms work by taking weighted
averages of input values and providing any other
necessary information to be able to recover the
original input
 Averaging of two values and differencing
6
Ch15-p.432
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
 suppose we are given two numbers, 14 and 22. We
can easily create their average
 To recover the original two values from their average,
we need a second value, the difference, obtained by
subtracting the average from the first value:
7
Ch15-p.432
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
 e.g.
The concatenation of v1 and v2 is the Discrete
wavelet transform at 1 scale of the original vector
8
Ch15-p.433
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
Discrete wavelet transform at 2 scales
Discrete wavelet transform at 3 scales
9
Ch15-p.433
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
 To recover the original vector
 At each stage, the averaging vector produces a
lower-resolution version of the original vector
10
Ch15-p.434
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
 Wavelet transforms produce a mix of lower
resolutions of the input and the extra information
required for inversion
 We notice that the differences may be small if the
input values are close together. This concept leads to
an idea for compression
 We apply a threshold by setting to zero all values in
the transform that are less than a predetermined
value
11
Ch15-p.434
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.1 Waves and Wavelets
 Threshold d3 with 0
 Use d’3 to recover the original vector
12
Ch15-p.434
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
 The Haar wavelet is defined by the function
13
Ch15-p.434
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
• 15.2.1 Applying the Haar Wavelet
 where the subscripts on φ(x) and ψ(x) represent
different dilations and shifts of the basic functions.
Then, we can recover f(x) with
14
Ch15-p.435
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
 The form of the equations above indicates that the
discrete wavelet transform can be written as a matrix
multiplication, as we saw for the DFT
 We will show below how this is done. Notice that the
Haar wavelet can be written in terms of the simpler
pulse function:
Mother wavelet
father wavelet
15
Ch15-p.435
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
Dilation equation
hi are called the filter coefficients (taps)
16
Ch15-p.436
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
17
Ch15-p.437
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
18
Ch15-p.437
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
 The averaging part of the wavelet corresponds to
low-pass filtering, in that we are coarsening or
blurring our input
 Similarly, the differencing part of the transform
corresponds to a high-pass filter
 Thus, a wavelet transform contains within it both
high- and low-pass filtering of our input, and we can
consider a wavelet transform entirely in terms of
filters
19
Ch15-p.438
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
• 15.2.2 Two-Dimensional Wavelets
 standard decomposition
20
Ch15-p.438
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.2 A simple Wavelet:
The Haar Wavelet
 nonstandard decomposition
21
Ch15-p.439
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.3 Wavelets in MATLAB
• We will use the UviWave toolbox, developed at the
University of Vigo in Spain. Its homepage is
http://www.tsc.uvigo.es/∼wavelets/uvi_wave.html
• It can also be found at other places on the Web
• Assuming that you have downloaded and installed the
toolbox
22
Ch15-p.439
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.3 Wavelets in MATLAB
 Here h and g are the low-pass and high-pass filter
coefficients for the forward transform
 rh and rg are the low-pass and high-pass filter
coefficients for the inverse transform
 The daub function produces the filter coefficients
for a class of wavelets called Daubechies wavelets,
of which the Haar wavelet is the simplest
23
Ch15-p.439
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.3 Wavelets in MATLAB
24
Ch15-p.440
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.3 Wavelets in MATLAB
25
Ch15-p.440
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.3 Wavelets in MATLAB
26
Ch15-p.441
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.6
27
Ch15-p.441
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.7
28
Ch15-p.442
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
29
Ch15-p.442
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
 As for the Haar wavelet, we can apply the Daubechies 4
wavelet by a matrix multiplication; the matrix for a one-scale
DWT on a vector of length 8 is
30
Ch15-p.443
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
 Notice that the filter coefficients overlap between
rows, which is not the case for the Haar matrix H 2
n
 This means that the use of the Daubechies 4 wavelet
will have smoother results than using the Haar
wavelet
31
Ch15-p.443
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
• Steps for performing a one-scale wavelet transform are
given by Umbaugh [37]:
1. Convolve the image rows with the low-pass filter
2. Convolve the columns of the result of Step 1 with the lowpass filter and rescale this to half its size by subsampling
3. Convolve the result of Step 1 with the high-pass filter and
again subsample to obtain an image of half the size
4. Convolve the original image rows with the high-pass filter
32
Ch15-p.444
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
5. Convolve the columns of the result of Step 4 with the lowpass filter and rescale this to half its size by subsampling
6. Convolve the result of Step 4 with the high-pass filter and
again subsample to obtain an image of half the size
• At the end of these steps there are four images, each
half the size of the original
33
Ch15-p.444
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.8
1.
2.
3.
4.
34
the low-pass/low-pass image (LL), the result of Step 2,
the low-pass/high-pass image (LH), the result of Step 3,
the high-pass/low-pass image (HL), the result of Step 5, and
the high-pass/high-pass image (HH), the result of Step 6
Ch15-p.444
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
 The filter coefficients of a wavelet are such that the
transform may be inverted precisely to recover the original
image
 Using filters, this is done by taking each subimage, zero
interleaving to produce an image of double the size and
convolving with the inverse low-pass and high-pass filters
 Finally, the results of all the filterings are added. For the
Daubechies 4 wavelet, the inverse low-pass and high-pass
filters are
35
Ch15-p.444
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
 A generalization to filtering: lifting
(Haar wavelet)
36
Ch15-p.445
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.4 The Daubechies Wavelets
 A lifting scheme for the Daubechies 4 wavelet is
37
Ch15-p.445
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.9
38
Ch15-p.446
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.10
39
Ch15-p.446
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.5 Image Compression Using
Wavelets
• 15.5.1 Thresholding and Quantization
40
Ch15-p.447
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.11
41
Ch15-p.448
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.12
42
Ch15-p.448
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.5 Image Compression Using
Wavelets
43
Ch15-p.449
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.13
44
Ch15-p.449
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.14
45
Ch15-p.450
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.15
46
Ch15-p.450
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.5 Image Compression Using
Wavelets
• 15.5.2 Extraction
47
Ch15-p.451
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.17
48
Ch15-p.452
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.6 High-Pass Filtering Using
Wavelets
49
Ch15-p.452
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.18
50
Ch15-p.453
© 2010 Cengage Learning
Engineering. All Rights Reserved.
15.7 Denising Using Wavelets
51
Ch15-p.453
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.19
52
Ch15-p.454
© 2010 Cengage Learning
Engineering. All Rights Reserved.
FIGURE 15.20
53
Ch15-p.454
© 2010 Cengage Learning
Engineering. All Rights Reserved.