Exercise 6 - ee.oulu.fi

Digital Image Processing
Exercise 6
FALL 2004
Answers
1.
Given NxN image I, its Haar transform is HIHT, where H is an NxN transformation matrix that should be
computed. H is created from the Haar functions.
Haar functions:
H 0 (t )  1,
0  t 1
 1, 0  t  1 2
H 1 (t )  
 1, 1 2  t  1
p

 2 ,

p
H 2 P  q (t )   2 ,

 0,

q
q  0.5
t 
p
2
2p
q  0.5
q 1
t  p
p
2
2
elsewhere
where p=1,2,3,… and q=0,1,…,2p-1.
The Haar functions are used to create the Haar transformation matrix as follows:



Calculate and plot the Haar functions of the continuous variable t by varying p and q.
Scale t by multiplying it by N, since an NxN image needs an NxN matrix.
Build entries of H from the plots of the Haar functions by taking discrete values of t: 0,1,…,N-1.

Normalize H by multiplying it by 1
N if t takes up N equally spaced discrete values.
1/8
Digital Image Processing, Exercise 6, answers
Haar functions:
2/8
Digital Image Processing, Exercise 6, answers
The Haar functions after scaling the t-axes:
Now discrete values of the Haar functions at t=0,1,2,3 (see them from the last four plots) form entries of the
transformation matrix. Thus, values of H(0,t) form the first row, values of H(1,t) form the second row, values
of H(2,t) form the third row, and values of H(3,t) form the forth row. A multiplier 1/2 appears so that HHT=I.
As a result,


1
H 
2



1
1
1
1
2
0
 2
0
1 

1 1 
0
0 

2  2 
1
and the solution is
3/8
Digital Image Processing, Exercise 6, answers
HIH T
2.


1
 
4



1
1
1
1
2
0
 2
0
1  0

 1  1  1
0
0  1

2  2  0
1
1 1 0 1 1
2

0 0 1 1 1  2
0 0 1 1  1
0



1 1 0 1  1
0
0  2
 
0  0

2   0

 2   0
0

0 0
0
0 1 1 

0 1  1
0
0
Wavelet Analysis
A wavelet is a waveform of effectively limited duration that has an average value of zero.
What can wavelet analysis do?



It is able to perform local analysis, that is, to analyze a localized area of a larger signal. Therefore
wavelet analysis can reveal what other techniques miss, namely, breakdown points, self-similarity,
and discontinuities in higher derivatives.
It analyzes a signal at more than one resolution (multiresolution). Therefore features that might go
undetected at one resolution may be easy to capture at another.
It can compress or de-noise signals with less degradations.
Wavelet analysis is based on the lowpass and highpass filtering. A lowpass filter cuts off high frequencies
while passing low ones. A highpass filter cuts off low frequencies while passing high ones.
For many signals, the low-frequency content is the most important part, since it is what gives a signal its
identity. The high-frequency content emphasizes details.
If we simply pass a signal through each filter, this will result in twice as much data as we started with. For
example, if the original signal contains 1,000 samples, we end up with 2,000 elements!
A simple solution is to perform downsampling after filtering. It means throwing away every second sample
so that in total, the number of coefficients will be equal to that of samples in the signal.
Let’s call the result of lowpass filtering as the approximation and the result of highpass filtering as the detail.
Data obtained after downsampling the approximation are approximation coefficients of the wavelet
transform and data obtained after downsampling the detail are detail coefficients of the wavelet transform.
One-step wavelet decomposition can be represented by the following chains:
coefficients
Signal  Lowpass Filtering  Downsampling approximat
ion


coefficients
Signal  Highpass Filtering  Downsampling det
ail


In the multistep decomposition, only the approximations are repeatedly decomposed while the details are
not!
The same procedure as described for the one-step decomposition is applied to the approximations at each
level of decomposition. For example, in order to get the decomposition at the second level, replace “Signal”
in the chain above with the “approximation coefficients” resulted from the first-level decomposition.
4/8
Digital Image Processing, Exercise 6, answers
The course book contains very descriptive diagrams graphically depicting the 1-D and 2-D wavelet
decompositions.
To compute the wavelet transform, we need two functions: scaling and wavelet.
The scaling function is used to create a series of approximations of an image, each differing by a factor 2
from its nearest neighboring approximations. The wavelet function is then used to encode the difference in
information between adjacent approximations. The scaling function for the Haar wavelet transform and
denoted as  (phi) is shown in the left figure (it is identical to the Haar function H(0,t)). The wavelet
function for the Haar wavelet transform and denoted as  (psi) is shown in the right figure (it is identical to
the Haar function H(1,t)).
The wavelet function is determined by the highpass filter and associated with details, while the scaling
function is determined by the lowpass filter and associated with approximations.
The 1-D scaling function is described by the formula:  j ,k ( x)  2 j / 2  (2 j x  k ) , where  (x ) is the scaling
function, k determines integer translations along the x-axis, j determines how broad or narrow the scaling
function, and 2j/2 controls the height or amplitude of the scaling function.
Several 1-D Haar scaling functions are given below.
5/8
Digital Image Processing, Exercise 6, answers
where  ( x)  1, 0  x  1 and 0, elsewhere.
The 1-D wavelet function is described by the formula:  j ,k ( x)  2 j / 2 (2 j x  k ) , where  (x ) is the
scaling function, k determines integer translations along the x-axis, j determines how broad or narrow the
scaling function, and 2j/2 controls the height or amplitude of the scaling function.
Several 1-D Haar wavelet functions are given below.
 1 0  x  0.5

where  ( x)   1 0.5  x  1
 0 elsewhere

6/8
Digital Image Processing, Exercise 6, answers
The 1-D discrete wavelet transform or DWT :
Approximation coefficients:
W ( j0 , k ) 
1
M
 f ( x)
j0 , k
( x)
x
Detail coefficients:
W ( j0 , k ) 
1
M
 f ( x)
j0 , k
( x)
x
M=2J, x=0,1,…,M-1, j=0,1,…,J-1, k=0,1,…,2j-1 and J is the number of scales.
Example: Let f(0)=1, f(1)=4, f(2)=-3, f(3)=0.
Therefore M=4, J=2, x=0,1,2,3, j=0,1, k=0 for j=0 and k=0,1 for j=1.
The DWT is computed as follows:
W (0,0) 
1 3
 f ( x) 0,0 ( x)  1
2 x 0
W (0,0) 
1 3
 f ( x) 0,0 ( x)  4
2 x 0
W (1,0) 
1 3
 f ( x) 1,0 ( x)  1.5 2
2 x 0
W (1,1) 
1 3
 f ( x) 1,1 ( x)  1.5 2
2 x 0
For Haar wavelets, the discretized scaling and wavelet functions correspond to the rows of the MxM Haar
transformation matrix computed in the previous exercise.
For example, the values for  0 , 0 are taken from the first row of this matrix; the values for  0, 0 are taken
from the second row of this matrix; the values for  1, 0 are taken from the third row of this matrix; the values
for  1,1 are taken from the forth row of this matrix.
7/8
Digital Image Processing, Exercise 6, answers
3.
See slides to this exercise.
8/8