0% found this document useful (0 votes)
20 views36 pages

C3 - Image Tranforms - P2 - NTHai-9-2015

The document discusses Wavelet Transforms, highlighting their significance in image processing and their comparison with Fourier and Short-time Fourier Transforms. It explains the concepts of Continuous Wavelet Transform (CWT) and Discrete Wavelet Transform (DWT), including their mathematical definitions and applications in analyzing signals. Various wavelet functions, such as Haar and Morlet, are introduced, along with examples of their implementation in MATLAB.

Uploaded by

viet.tranlequoc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views36 pages

C3 - Image Tranforms - P2 - NTHai-9-2015

The document discusses Wavelet Transforms, highlighting their significance in image processing and their comparison with Fourier and Short-time Fourier Transforms. It explains the concepts of Continuous Wavelet Transform (CWT) and Discrete Wavelet Transform (DWT), including their mathematical definitions and applications in analyzing signals. Various wavelet functions, such as Haar and Morlet, are introduced, along with examples of their implementation in MATLAB.

Uploaded by

viet.tranlequoc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

University of Technology and Education

Faculty of Electrical & Electronic Engineering

Lecture:
IMAGE PROCESSING
Chapter 3: Image Transforms
Wavelet Transforms

Nguyen Thanh Hai, PhD


1
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

• Fourier Transform (FT), the analyzing function is the


complex exponential   .

• Short-time FT (STFT), the analyzing function is the


complex exponential   and ∗ ( − )

• Wavelet Transform (WT), the analyzing function is a


wavelet .

• The WT using operators as shifting and compressing,


convoluting or stretching of a wavelet.

2
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Wavelet Analysis
Wavelet analysis is based on Multiresolution Analysis (MRA) in time-
frequency as shown in Fig. 3.7

Fig. 3.7. Analysis of time-frequency


with MRA.

3
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
- Wavelet analysis is considered between a signal x(t) and Wavelet
function (), in which wavelet () is considered as mother wavelet
function.
- Wavelet function () is a small signal or oscillation for distinguishing
different frequencies of the input signal.
- Wavelet contains information of analysis waveform and window
size (scale) as shown in Fig. 3.8
- In practice, there are many different wavelet family.

Fig. 3.8. Morlet Wavelet family 4


Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Continuous wavelet transform (CWT) of 1D is defined as follows:

1 −
,  =  ,  =  () ∗

  

 , is the two-variables function or called the wavelet coefficient


,  , with shifting position and scaling parameter . Mother wavelet
function is represented , symbol * is described complex operator.

Inverse Continuous wavelet transform (ICWT) of 1D is defined as follows:

 
1 1 −
  =     ,   
    

%⁄
 =     ! ,  = "#$   &

5
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Image Transforms
- Việc tính toán biến đổi Wavelet thường thực hiện với những giá trị rời rạc
ứng với các hệ số tỷ lệ  và độ dịch chuyển . Các hệ số Wavelet được gọi
là chuỗi Wavelet. Chuỗi Wavelet có thể được tính như sau


(,) =    *,+  


*/
*,+ = , ,*  − . ,

Số nguyên / và . điều chỉnh độ dịch chuyển và độ giản của sóng Wavelet.


Ứng với lược đồ nhị nguyên (dyadic grid), , = 0 và , = 1. Các sóng
Wavelet này được lựa chọn sao cho trực chuẩn, nghĩa là, chúng trực giao
với nhau và được chuẩn hóa để có mức năng lượng đơn vị. Việc lựa chọn
này cho phép xây dựng lại tín hiệu gốc thông qua biểu thức rời rạc sau:
 

  = 1 1 (,) *,+ 
*2 +2
6
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Image Transforms

Fig. 3.9. Input signal with different frequencies and waveforms

7
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
• Many different wavelets can be used in CWT.
• Depending on signal features to be detected  select a
wavelet for analysis easier.

a) Gauss b) Mexican hat

c) Haar
d) Morlet

8
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Image Transforms
1D Haar Wavelets
• Haar scaling and wavelet functions:
• Mother scaling function: φ(t)

• Mother wavelet function: ψ(t)

Nguyen Thanh Hai, PhD


University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Continuous wavelet transform (CWT)_Scale
• Example: sine signal with different scales

10
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Continuous wavelet transform (CWT)_Scale
• The scale works exactly the same with wavelet

11
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
With the 1D discrete signal # . , the DWT is determined using the
following equation:
1
34 5, , 6 = 1 #(.)89 ,: (.)
7 +

1
3 5, 6 = 1 #(.) ,: (.) 5 ≥ 5,
7 +
In which, 89 ,: (.) and ,: (.) are functions of scaling and discrete
Wavelet determined in the interval 0, 7 − 1 and orthogonal together
with 5, initially
- 34 5, , 6 expresses the approximation coefficient (low
frequencies),
- 3 5, 6 are the detail coefficients (high frequencies).
The inverse DWT is calculated as follows:

1 1
# . = 1 34 5, , 6 89 ,: . + 1 1 3 5, 6 ,: .
7 :
7 2 :
9 12
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Discrete Wavelet transform (DWT) in digital image
This is the 2D wavelet function, including scaling 8 , = and Wavelet
, = and calculated as follows:

8,*,+ , = = 2/ 8 2  − /, 2 = − . ,

?
,*,+ , = = 2/ ?
2  − /, 2 = − . , @ = A, B, C

3 wavelet functions D (, =), E (, =), F , = , are still called details;
and 8G , = is called approximation.

In the DWT, one takes care 4 variables

8 , = = 8  8 = , E , = = 8  = ,
D , = =  8 = , F
, = =  = ,

13
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Discrete Wavelet transform (DWT) in digital image
Expressions of the approximation and details are described in 2D image
as follows:
LJ IJ
1
34 5, , /, . = 1 1 # , = 89 ,*,+ , = = G
7H M2, K2,

LJ IJ
1 ?
3 5, /, . = 1 1 # , = 8,*,+ , = , @ = A, B, C
7H M2, K2,

# , =
LJ IJ
1
= 1 1 34 5,,*,+ 89 ,*,+ , =
7H M2, K2,

1
+ 1 1 1 1 3? 5, /, . 8,*,+
?
, =
7H ?2D,E,F 2 * +
9
14
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Diagram of the wavelet transform of an image:

15
Nguyen Thanh Hai, PhD.
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

16
Nguyen Thanh Hai, PhD.
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Fig. Expression of components in an image

17
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Some wavelet functions in Matlab:

- [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('wname');
In which, Lo_D and Hi_D are the lowpass and highpass filters. Lo_R và Hi_R
are the lowpass and highpass filters for synthesis, in which the filters must
be orthogonal.
- Function wfilters to find types of different wavelets:
[F1,F2] = wfilters('wname','type')
- wavefun :
[phi, psi, xval] = wavefun(vname,iter)
Give approximate vector of phi and psi, and xval is vector ước lượng; iter
describes integer numbers
- If variables are orthogonal, we have :
[phi1, psi1, phi2, psi2, xval] = wavefun(wname, iter)
In which phi1 and psi1 are decomposition, phi2 and psi2 are recontruction.

18
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Ex 3.3: Express filter, scaling and plot(xval,psi,'k',xval,xaxis,'--k');


wavelet functions of Haar. axis([0 1 -1.5 1.5]);
clear all; axis square;
[Lo_D,Hi_D,Lo_R,Hi_R] = title('Haar Wavelet Function');
wfilters('Haar')
waveinfo('Haar') Results:
[phi,psi,xval]=wavefun('Haar',10) >>
xaxis=zeros(size(xval)); Lo_D =
subplot(121); 0.7071 0.7071
plot(xval,phi,'k',xval,xaxis,'--k'); Hi_D =
axis([0 1 -1.5 1.5]); -0.7071 0.7071
axis square; Lo_R =
title('Haar Scaling Function') 0.7071 0.7071
subplot(122); Hi_R =
0.7071 -0.7071

19
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Some wavelet functions in Matlab:
wavedec2:
[C, S] = wavedec2(X, N, Lo_D, Hi_D)
In which, X is the 2D matrix, N is the analysis level, Lo_D and Hi_D are the
filters. syntax:
[C,S] = wavedec2(X,N,'wname')
Output is row vector C (double) containing Wavelet coefficients and the
matrix S (double) determines coefficients in C. The relationship between C
and S is described as:

Fig 3.20. Scaling and Wavelet of Haar family


20
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Ex 3.4: Consider wavelet transform
using wavedec2 with Haar family
C=
clear all; Columns 1 through 10
f=magic(4); 17.0000 17.0000
17.0000 17.0000
[C,S]=wavedec2(f,1,'Haar'); 1.0000 -1.0000 -1.0000
1.0000 4.0000 -4.0000
magic(m) function give square matrix Columns 11 through 16
with the size of / , having the value -4.0000 4.0000
of elements from 1 to / . 10.0000 6.0000 -6.0000
-10.0000
f=
16 2 3 13 S=
5 11 10 8 2 2
9 7 6 12 2 2
4 14 15 1 4 4

21
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Ex 3.5: Extract Wavelet coefficients - A = appcoef2(C,S,'wname',N)


small bands with a typical level - A = appcoef2(C,S,Lo_R,Hi_R,N) is
similar to detcoef2
clear all;
f=magic(4);
[C,S]=wavedec2(f,2,'Haar');
A=appcoef2(C,S,'Haar',1)
V=detcoef2('v',C,S,2)% vD
H=detcoef2(‘h',C,S,2)% hD
D=detcoef2(‘d',C,S,2)% dD

In which appcoef2 gives


approximation coefficient, and
detcoef2 gives detail coefficients;
wavedec2 denotes decomposition
wavelet with a typical wavelet
function.
22
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Ex 3.6: Calculate DWT with the 4x4 matrix of magic function and
Haar family.
The resulat is that

16 2 3 13
# = 5 11 10 8
9 7 6 12
4 14 15 1

With the lowpass and highpass filters (orthogonal):


J J J J
UV_C =   và A@_C =  

- Approximation components contain coefficients with low


frequencies using the lowpass filter.

23
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Convolution of the image # and the lowpass filter UV_C cross the
row of the matrix.

24
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

25
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

26
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

. .
(0) . (0)
(1) (0) 0
 = (2) 2 = (2) 2 2 = (2)
(3) (4) 0
(4) . (4)
. .

27
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Ex 3.7: Express wavelet with an image

clear all;
f=imread('cameraman.bmp');
[cA1,cH1,cV1,cD1]=dwt2(f,'Haar');

f1=[mat2gray(cA1) mat2gray(cH1);mat2gray(cV1)
mat2gray(cD1)];
[cA2,cH2,cV2,cD2]=dwt2(cA1,'Haar');

f22=[mat2gray(cA2) mat2gray(cH2);mat2gray(cV2)
mat2gray(cD2)];

f2=[f22 mat2gray(cH1);mat2gray(cV1) mat2gray(cD1)];


imshow(f1);
figure;imshow(f2);

28
Nguyen Thanh Hai, PhD
University of Technical Education
Faculty of Electrical & Electronic Engineering
Wavelet transform
Wavelet toolbox : dwt2 (cont)

29
Nguyen Thanh Hai, PhD.
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Ex 3.8: Express WT with noise

clear all
f=imread('cameraman.bmp');
fn=imnoise(f,'gaussian',0.01);
[cA,cH,cV,cD]=dwt2(fn,'Haar');
[THR_H,SORH_H,KEEPAPP_H]=dde
ncmp('den','wv',cH);
cH=wthresh(cH,SORH_H,THR_H);
[THR_V,SORH_V,KEEPAPP_V]=dden
cmp('den','wv',cV);
cV=wthresh(cH,SORH_V,THR_V);
[THR_D,SORH_D,KEEPAPP_D]=dde
ncmp('den','wv',cD);
cD=wthresh(cH,SORH_D,THR_D);
fdn=uint8(idwt2(cA,cH,cV,cD,'Haar'));

30
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

31
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

- Consider functions idwt2, dwt2,


X = idwt2(cA,cH,cV,cD,'wname')

- Image after pepper-salt noise.


- This is the noise with the high frequency affecting
details of the image. Thus the algorithm for eliminating
the noise used details components with the highpass
filter cH, cV and cD.

32
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms
Ex: express WT of a 5x5 matrix

• Find DWT of #=

J J
• Using wavelet Haar, in which: UV_C =  
and A@_C =
J J
 

33
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Tip: access the ‘wavedec2’ function root and compare to your answer
34
Nguyen Thanh Hai, PhD
University of Technology and Education
Faculty of Electrical & Electronic Engineering
Wavelet Transforms

Example: clear all;


f=imread('cameraman.bmp');
[cA1,cH1,cV1,cD1]=dwt2(f,'Haar');
f1=[mat2gray(cA1) mat2gray(cH1);mat2gray(cV1)
mat2gray(cD1)];

Wavelet toolbox
[C,S] = wavedec2(X,N,'wname')
Example: clear all;
f=magic(4);
[C,S]=wavedec2(f,1,'Haar');

35
Nguyen Thanh Hai, PhD.
University of Technical Education
Faculty of Electrical & Electronic Engineering
Image Transforms

The End

36
Nguyen Thanh Hai, PhD

You might also like