december 15,2016 juan pablo madrigal cianci trevor...

52
Denoising and Compression Using Wavelets December 15,2016 Juan Pablo Madrigal Cianci Trevor Giannini

Upload: others

Post on 23-Feb-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

Denoising and Compression Using Wavelets

December 15,2016

Juan Pablo Madrigal CianciTrevor Giannini

Page 2: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

1Agenda

Introduction

Mathematical Theory

Theory

MATLAB’s Basic Commands

De-Noising: Signals

De-Noising: Images

De-noising: Video

Compression

Applications of Compression

Final Comments

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 3: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

2introduction

I It is well known to any scientist and engineer who work with areal world data that signals do not exist without noise, eithernegligible or not negligible.

I However, there are many cases in which the noise corrupts thesignals in significant manner, and it must be removed from thedata in order to proceed with further data analysis. The processof noise removal is generally referred to as signal denoising orsimply denoising.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 4: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

3introduction: Denoising

I Since the 1990s, wavelets have been found to be a powerful toolfor removing noise from a variety of signals (denoising). Theyallow to analyze the noise level separately at each wavelet scaleand to adapt the denoising algorithm accordingly.

I Wavelet thresholding methods for noise removal, in which thewavelet coefficients are thresholded in order to remove theirnoisy part, were first introduced by Donoho in 1993.

I We consider a Gaussian additive noise model, meaning that ifour noisy signal can be modeled as

y(t) = x(t) + εµ,σ,

that is, our noisy signal (or image) is composed by a clean imageplus some random noise with mean µ and standard deviation σ.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 5: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

4introduction: Denoising

I The main idea is then to decompose the wave using the DWT.I Then we use a threshold for the coefficients and as such get rid

of some of them.I After obtaining the coefficients that we decide to keep, we the

recostruct our image using the IDWT

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 6: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

5introduction: Compression

Now, let’s talk about compression.I The goal of compression is to store image data in as little space

as possible in a file. Used in JPEG files.I The compression method is as follows.

1. First, we use a wavelet transform. This will produce as manycoefficients as there are pixels in the image.

2. These coefficients can then be compressed more easily becausethe information is statistically concentrated in just a few coefficients.

3. After that, the coefficients are quantized and the quantized valuesare entropy encoded and/or run length encoded.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 7: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

6introduction: Compression

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 8: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

7Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Let ψn,m,j,k (x)(y) := ψm,k (x)ψm,j(y), where n,m, j , k ∈ Z. We knowthat ψn,k (x) forms an orthonormal basis in L2(R). Thus we need toshow that ψn,m,k,j(x)(y) forms an orthonormal basis in L2(R2). Thuswe want to show that given a f ∈ L2(R2),

f (x , y) =∑n∈Z

∑m∈Z〈f , ψn,m〉ψn,m(x , y),

where ψn,m(x , y) = ψn(x)ψm(y).

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 9: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

8Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Define f (x , y) := fx(y). We start by fixing an x ∈ R. Note that sincef ∈ L2(R2) then f (x , y) = fx(y) ∈ L2(R). for almost every x ∈ R. Let

fx(y) =∑n∈Z〈fx , ψm〉ψm(y). (1)

=⇒ f (x , y) =∑n∈Z〈fx , ψm〉ψm(y), (2)

(3)

where the last equality is made in the L2(R) sense. Moreover, let

Fm(x) = 〈fx , ψm〉 =∫ ∞−∞

f (x , z)ψm(z)dz ∈ L2(R), since f ∈ L2(R2).

(4)

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 10: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

9Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Moreover, since ψn(x) is a basis in L2(R) and fm(x) ∈ L2(R), we havethat

Fm(x) =∑n∈Z〈Fm, ψn〉ψn(x). (5)

We need to show that Fm(x) ∈ L2(R). To do so we compute

||Fm||2 =

∫ ∞−∞|Fm(x)|2dx =

∫ ∞−∞|∫ ∞−∞

f (x , z)ψm(z)dz|2dx (6)

≤∫ ∞−∞

(∫ ∞−∞|f (x , z)|2dz

∫ ∞−∞|ψm(z)|2dz

)dx (7)

=

∫ ∞−∞

∫ ∞−∞|f (x , z)|2dzdx = ||f (x , z)||2 <∞, (8)

=⇒ Fm(x) ∈ L2(R), (9)

where we used Cauchy-Schwarz from equation (7) to equation (8)and equation (8) is true because ||ψm|| = 1.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 11: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

10Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Also, note that

〈Fm, ψn〉L2(R) =

∫ ∞−∞

Fm(x)ψn(x)dx = (10)∫ ∞−∞

∫ ∞−∞

f (x , z)ψm(z)ψn(x)dzdx , (11)

where we used Foubini’s theorem between (11) and (12)

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 12: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

11Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Thus

f (x , y) =∑m∈Z

(∑n∈Z〈Fm, ψn〉L2(R)ψn(x)

)ψm(y) (By eq. (6)) (12)

=∑m∈Z

∑n∈Z〈f , ψmψn〉L2(R2)ψn(x)ψm(y) (13)

=∑m∈Z

∑n∈Z〈f , ψn,m〉L2(R2)ψm,n(x , y) (14)

(15)

=⇒ ψm,n(x , y) is a complete system in L2(R2).

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 13: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

12Mathematical Aspects

{ψn,m} is a Complete System L2(R2)Thus having show that it is indeed a basis, we want to show that it’salso orthonormal, i.e,

〈ψn,m, ψp,q〉 = δ(p,q),(n,m). (16)

To do so consider

〈ψn,m, ψp,q〉 =∫ ∞−∞

∫ ∞−∞

ψp(x)ψq(y)ψn(x)ψm(y)dxdy (17)

=

∫ ∞−∞

ψq(y)ψm(y)(∫ ∞−∞

ψp(x)ψn(x)dx)

dy (18)

=

∫ ∞−∞

ψq(y)ψm(y)δp,ndy = δp,n

∫ ∞−∞

ψq(y)ψm(y)dy (19)

= δp,nδq,m = δ(p,q),(n,m) (20)

Therefore, we have that {ψn,m} is an orthonormal basis in L2(R2).Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 14: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

13Mathematical Aspects

Proof that they form an Orthogonal MRALet Vj = vj ⊗ vj . Naturally, this means that Vj+1 = vj+1 ⊗ vj+1. Wewant to show Vj ⊆ Vj+1. We assume that we are in an FIR. Thus it issufficient to show that the basis elements of Vj are in Vj+1.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 15: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

14Mathematical Aspects

Proof that they form an Orthogonal MRALet’s examine the basis elements of Vj .

Vj = span{φj,k (x)φj,n(y)} = span{φj,k (x)φj,n(y)} (21)

= span{φj,k,n(x , y)} = {∑n∈Z

aj,k,nφj,k,n(x , y)|∑n∈Z|aj,k,n|2 <∞}. (22)

Where the right hand side of (22) is closed since we have all possibleproducts here, including the limit of sequences.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 16: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

15Mathematical Aspects

Proof that they form an Orthogonal MRAMoreover, we have that φj,k,b(x , y) are the basis elements. Withoutloss of generality, we assume that j = 0, otherwise the arguement isidentical but the notation might vary slightly. As we know, the scalingfunctions in 1-D were φ(x) and φ(y). We define our scaling functionin 2-D as φ(x , y) := φ(x)φ(y). Clearly, since φ(x), φ(y) ∈ V0, thenφ(x , y) ∈ V0 ⊗ V0.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 17: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

16Mathematical Aspects

Proof that they form an Orthogonal MRARecall that φj,n(x) = 2J/2φ(2Jx − n). This in turn implies that

φj,n,k (x , y) = 2Jφ(2Jx − n)φ(2Jy − k) = 2Jφ(2jx −m,2Jy − k) (23)=⇒ φ0,n,k (x , y) = φ(x − n, y − k), (24)

for j = 0. We thus need to show that φ0,n,k (x , y) ∈ V1 ⊗ V1. Recallthat {φ0,n(x)} is an orthonormal basis for V1 and that the set ofscaled-translates of φ(2x), {21/2φ(2x − n)} form an orthonormalbasis for V1.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 18: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

17Mathematical Aspects

Proof that they form an Orthogonal MRAThus a basis for V0 ⊗ V0 is given by

{φ1,k (x)φ1,n(y)} = {φ1,n,k (x , y)} = {2φ(2x − n,2y − k)} (25)

Thus, we need to show that

φ(x − n, y − k) = 2∑p∈Z

∑q∈Z

hp,qφ(2x − p,2y − p)

, which is a finite sum since we assumed that we had an FIR. Thus,φ(x) = φ0,0(x) =

∑p∈Z hpφ1,p(x) is a finite sequence.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 19: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

18Mathematical Aspects

Proof that they form an Orthogonal MRAThis in turn implies that

φ0,n(x) = φ(x − n) =∑p∈Z

hpφ1,p(x − n) =∑p∈Z

hp21/2φ(2(x − n)− p) (26)

=∑p∈Z

hp21/2φ(2x − (2n + p)). Let r = 2n + p =⇒ p = r − 2n (27)

∑r∈Z

hr−2nφ(2x − r) =∑r∈Z

hr−2nφ1,r (x) (28)

=⇒ φ0,n(x) =∑r∈Z

hr−2nφ1,r (x). (29)

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 20: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

19Mathematical Aspects

Proof that they form an Orthogonal MRASimilarly, φ0,k (x) =

∑s∈Z hs−2kφ1,s(y), which implies that

φ0,n,k (x , y) = φ0,n(x)φ0,k (y) =∑r∈Z

∑r∈Z

hr−2nhs−2kφ1,r (x)φ1,s(y) (30)

=∑r∈Z

∑r∈Z

hr ,s,n,kφ1,r ,s(x , y) (31)

=⇒ φ0,n,k ∈ V1 ⊗ V1 (32)

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 21: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

20Mathematical Aspects

Fast Wavelet Transform.The Fast Wavelet Transform is a mathematical algorithm designed toturn a waveform or signal in the time domain int o a sequence ofcoefficients based on an orthogonal basis of small finite waves, orwavelets. The transform can be easily extended to multidimensionalsignals, such as images, where the time domain is replaced with thespace domain.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 22: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

21Mathematical Aspects

Fast Wavelet Transform (Cont.).It has as theoretical foundation the device of a finitely generated,orthogonal multiresolution analysis (MRA). In the terms given there,one selects a sampling scale J with sampling rate of 2J per unitinterval, and projects the given signal f onto the space VJ ; in theoryby computing the scalar products

s(J)n = 2J〈f (t), φ(2J t − n)〉. (33)

where φ is the scaling function of the chosen wavelet transform

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 23: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

22Mathematical Aspects

Fast Wavelet Transform (Cont.).in practice by any suitable sampling procedure under the conditionthat the signal is highly oversampled, so

PJ [f ](x) =∑n∈Z

s(J)n φ(2Jx − n)

is the orthogonal projection or at least some good approximation ofthe original signal in VJ . The MRA is characterized by its scalingsequence a = (a−N , . . . ,a0, . . . ,aN) and its wavelet sequenceb = (b−N , . . . ,b0, . . . ,bN) (some coefficients might be zero). Thoseallow to compute the wavelet coefficients d (k)

n , at least some rangek = M, ..., J − 1, without having to approximate the integrals in thecorresponding scalar products. Instead, one can directly, with thehelp of convolution and decimation operators, compute thosecoefficients from the first approximation s(J).

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 24: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

23Mathematical Aspects

Mallat’s Algorithm.I In 1988, Mallat produced a fast wavelet decomposition and

reconstruction algorithm. The Mallat algorithm for discretewavelet transform (DWT).

I It is, in fact, a classical scheme in the signal processingcommunity, known as a two-channel subband coder usingconjugate quadrature filters or quadrature mirror filters (QMFs).

I Denote Ai and Di as the i th approximate and detailed coefficientsrespectively.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 25: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

24Mathematical Aspects

Mallat’s Algorithm (Cont.).The algorithm goes as follows:

1. the decomposition algorithm starts with signal s, next calculatesthe coordinates of A1 and D1, and then those of A2 and D2, andso on.

2. The reconstruction algorithm called the inverse discrete wavelettransform (IDWT) starts from the coordinates of AJ and DJ , nextcalculates the coordinates of AJ−1, and then using thecoordinates of AJ˘1 and DJ˘1 calculates those of AJ˘2, and so on.More precisely, the algorithm is given by

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 26: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

25Mathematical Aspects

Mallat’s Algorithm (Cont.).

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 27: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

26MATLAB ’s Basic Commands

I MATLAB has its own in-built functions to apply wavelets to signals,images, etc.

I The wavelet toolbox includes different wavelets to work with.Among them are Haar, Doubechies, symlets (almost symmetricwavelet), and many more.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 28: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

27MATLAB ’s basic Commands

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 29: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

28Signals

BasicsTo denoise a signal (1D Wave) in MATLAB we can use the inbuiltfunction wden(X,TPTR,SORH,SCAL,N,WNAME), where

I (X) is our noisy signalI (TPTR) Is the threshold selection ruleI (SOHR) Specifies if soft or hard thresholdingI (SCAL) ScaleI (N) Wavelet levelI (WNAME) Wavelet Name

So let’s use it in an example.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 30: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

29Signals

Result

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 31: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

30Signals

I Let’s consider two other examples that are not as manufactured:Sound denoising and denoising of a raw a raw signal.

I The idea is the same as before; we pick a wavelet, a threshold, alevel and use MATLAB’s Inbuilt function wden. The results are asfollows

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 32: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

31Signals

ECGI We obtained raw data from an ECG. The data looks like

Figure:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 33: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

32Signals

ECGI As we can see it’s very noisy!I in practice, we would like to distinguish 4 peaks

I Thus, we denoise with a soft threshold and a symlet (modifyedversion of a Daubechies wavelet with increased symmetry) andget the following:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 34: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

33Signals

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 35: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

34Signals

Using different wavelets we get the following figure. Note the bigdifference between Haar and the other two!

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 36: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

35Signals

I Finally, we consider one last type of wave: A noisy audio file.Performing a denoising using a Biorthogonal wavelet and a softthresholding we get the following:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 37: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

36Images

AlgorithmThe code for two dimensional case is a little more complicated. Thesteps are:

1. Convert our image into a matrix using I=imread(’name offile.ext’).

2. Convert our image into gray scale by using I=rgb2gray(I).3. Obtain the decomposition coefficients by [C,S] =

wavedec2(J,level,wname).4. Use thr = wthrmngr(’dw2ddenoLVL’,...

’penalhi’,C,S,1) in order the obtain the threshold5. finally, use

[XDEN,cfsDEN,dimCFS] =wdencmp(’lvd’,C,S,wname,level,thr,sorh) in order toperform the denoising.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 38: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

37Images

The process is as follows:I Load the image file into MATLAB and convert it to a matrix using

the command X=imread(’imagename.extI Obtain the wavelet decomposition of said matrix using the

command [C,S]=wavedec2(X,N,’wavelet name’)I Compute the thresholding using the function thr =

wthrmngr(’dw2ddenoLVL’,’penalhi’,C,S,1)I Perform the denoising using

wdencmp(’lvd’,C,S,wname,level,thr,sorh)

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 39: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

38Image Denoising

Let’s show some examples. Consider the following picture:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 40: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

39Image Denoising

Denoising the image using a bi-orthogonal wavelet we get thefollowing result:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 41: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

40Image Denoising

Note, however that the denoised images can get very sensitive withrespect to the wavelet we use. If we use a less-smooth wavelet, likeHaar, we get the following

In which case the noisy image seems to be better than the denoisedone!

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 42: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

41Image Denoising

Let’s repeat the experiment with a nicer picture and a larger choice ofwavelets. Consider the following picture:

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 43: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

42Image Denoising

Denoising the image with a soft threshold and a varity of waveletsgives the following results

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 44: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

43Video Denosing

I Videos are made out of pictures and usually contain between 30to 60 pictures per second and an underlying sound track.

I Thus, we can combine the image denoising code and the sounddenoising code in order to denoise a video.

I To do so, we need to extract each of these frames and denoisethem one by one.

I Clearly this is a process that takes time; we need to perform thedenoising computation between 30 to 60 times per second ofvideo. An alternative to this would be to implement this processin parallel!

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 45: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

44Compression

Compression algorithm in MATLABThe compression algorithm is fairly similar to the image denoisingalgorithm.

1. Do the 2-dimensional wavelet composition using [c l] =wavedec2(x,n,w)

2. Perform the compression using[xd,cxd,lxd,perf0,perfl2] =wdencmp(opt,c,l,w,n,thr,sorh,keepapp);

The code is implemented in the following slides.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 46: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

45Image Compression

Consider the following image to which we will perform compressionwith different threshold

Figure: Image from the MATLAB .Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 47: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

46Image Compression

Figure: Different thresholding levels

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 48: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

47Image Compression

Now, let’s consider a different picture with a higher resolution.

Figure: A higher resolution picture of Audrey Hepburn.

Compressing this image for higher thresholding values we get thatJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 49: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

48Image Compression

Figure: Compression for different threshold levels.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 50: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

49Final Remarks

Some final comments:

I As we can see, we can apply wavelets in order to denoise asignal, an image or even a video! As mentioned in the beginning,Many (if not most) real problems in Engineering and sciencehave some noise associated to them.

I As you might have noticed, all the denoising we did was un blackand white pictures. This is not coincidental; it is morecomplicated to denoise colored images.

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 51: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

50Selected References

I Pereyra, María Cristina, and Lesley A. Ward. Harmonic analysis:from Fourier to wavelets. Vol. 63. American Mathematical Soc.,2012.

I Mallat, Stéphane G., and Zhifeng Zhang. "Matching pursuits withtime-frequency dictionaries." IEEE Transactions on signalprocessing 41.12 (1993): 3397-3415.

I Rami Cohen. Signal Denoising Using Wavelets. 2012. Technion,Technical Institute of Israel.

I Misiti, Michel, et al. "Matlab Wavelet Toolbox Users Guide.Version 3." (2004).

Juan Pablo Madrigal Cianci Trevor Giannini | Denoising and Compression Using Wavelets

Page 52: December 15,2016 Juan Pablo Madrigal Cianci Trevor Gianninicrisp/courses/wavelets/fall16/JuanPabloTrevor2DwaveletsSlides.pdfJuan Pablo Madrigal Cianci Trevor Giannini | Denoising and

Questions?Thank you for your time!