discrete haar wavelet transforms - university of st....

127
Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom Discrete Haar Wavelet Transforms Patrick J. Van Fleet Center for Applied Mathematics University of St. Thomas St. Paul, MN USA PREP - Wavelet Workshop, 2006 Wednesday, 7 June, 2006 Lecture 4 Discrete Haar Wavelet Transforms

Upload: doandung

Post on 25-Apr-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Discrete Haar Wavelet Transforms

Patrick J. Van Fleet

Center for Applied MathematicsUniversity of St. Thomas

St. Paul, MN USA

PREP - Wavelet Workshop, 2006

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 2: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

OutlineToday’s ScheduleBuilding the Haar Matrix

Putting Two Filters TogetherWhy the Word Wavelet?Examples

Coding the Haar TransformImplementing WNImplementing W T

N2D Haar Transform

Building the 2D TransformCoding the 2D Transform

IteratingIn the Classroom

Teaching IdeasComputer UsageWednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 3: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Today’s Schedule

9:00-10:15 Lecture One: Why Wavelets?10:15-10:30 Coffee Break (OSS 235)10:30-11:45 Lecture Two: Digital Images, Measures, and

Huffman Codes12:00-1:00 Lunch (Cafeteria)1:30-2:45 Lecture Three: Fourier Series, Convolution and

Filters2:45-3:00 Coffee Break (OSS 235)3:00-4:15 ⇒Lecture Four: 1D and 2D Haar Transforms5:30-6:30 Dinner (Cafeteria)

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 4: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Consider again the filter h = (h0,h1) = (12 ,

12).

I If we compute y = h ∗ x, we obtain the components

yn =12

xn +12

xn−1

I We could write down the convolution matrix

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 5: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Consider again the filter h = (h0,h1) = (12 ,

12).

I If we compute y = h ∗ x, we obtain the components

yn =12

xn +12

xn−1

I We could write down the convolution matrix

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 6: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Consider again the filter h = (h0,h1) = (12 ,

12).

I If we compute y = h ∗ x, we obtain the components

yn =12

xn +12

xn−1

I We could write down the convolution matrix

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 7: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Consider again the filter h = (h0,h1) = (12 ,

12).

I If we compute y = h ∗ x, we obtain the components

yn =12

xn +12

xn−1

I We could write down the convolution matrix

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 8: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

H =

. . . . . . . . . . . .0 0 0 1

212 0 0 0 0 0 0 0 0

0 0 0 0 12

12 0 0 0 0 0 0 0

. . . 0 0 0 0 0 12

12 0 0 0 0 0 0 . . .

0 0 0 0 0 0 12

12 0 0 0 0 0

0 0 0 0 0 0 0 12

12 0 0 0 0

. . . . . . . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 9: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I . . . but we can’t invert the process.I What would we need to be able to invert the process?I We have averages of consecutive numbers - if we had the

directed distance between these averages and theconsecutive numbers, then we could invert.

I The directed distance is exactly the sequence x convolvedwith the filter g = (1

2 ,−12).

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 10: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I . . . but we can’t invert the process.I What would we need to be able to invert the process?I We have averages of consecutive numbers - if we had the

directed distance between these averages and theconsecutive numbers, then we could invert.

I The directed distance is exactly the sequence x convolvedwith the filter g = (1

2 ,−12).

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 11: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I . . . but we can’t invert the process.I What would we need to be able to invert the process?I We have averages of consecutive numbers - if we had the

directed distance between these averages and theconsecutive numbers, then we could invert.

I The directed distance is exactly the sequence x convolvedwith the filter g = (1

2 ,−12).

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 12: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I . . . but we can’t invert the process.I What would we need to be able to invert the process?I We have averages of consecutive numbers - if we had the

directed distance between these averages and theconsecutive numbers, then we could invert.

I The directed distance is exactly the sequence x convolvedwith the filter g = (1

2 ,−12).

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 13: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I . . . but we can’t invert the process.I What would we need to be able to invert the process?I We have averages of consecutive numbers - if we had the

directed distance between these averages and theconsecutive numbers, then we could invert.

I The directed distance is exactly the sequence x convolvedwith the filter g = (1

2 ,−12).

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 14: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

Indeed if

yn =12

xn +12

xn−1 and zn =12

xn −12

xn−1

then

xn = yn + zn and xn−1 = yn − zn

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 15: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

Perhaps we could invert the process if we used both filters. Weknow that G is

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 16: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

G =

. . . . . . . . . . . .0 0 0 − 1

212 0 0 0 0 0 0 0 0

0 0 0 0 − 12

12 0 0 0 0 0 0 0

. . . 0 0 0 0 0 − 12

12 0 0 0 0 0 0 . . .

0 0 0 0 0 0 − 12

12 0 0 0 0 0

0 0 0 0 0 0 0 − 12

12 0 0 0 0

. . . . . . . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 17: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

So that H

G

· x =

y

z

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 18: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

If we think about inverting, we can write down:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 19: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

......

y1 − z1 =x1 + x0

2− x1 − x0

2= x0

y1 + z1 =x1 + x0

2+

x1 − x0

2= x1

y2 − z2 =x2 + x1

2− x2 − x1

2= x1

y2 + z2 =x2 + x1

2+

x2 − x1

2= x2

y3 − z3 =x3 + x2

2− x3 − x2

2= x2

y3 + z3 =x3 + x2

2+

x3 − x2

2= x3

......

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 20: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

But there is some redundancy here - we do not need all thevalues of yn, zn to recover xn:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 21: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

......

y1 − z1 =x1 + x0

2− x1 − x0

2= x0

y1 + z1 =x1 + x0

2+

x1 − x0

2= x1

y2 − z2 =x2 + x1

2− x2 − x1

2= x1

y2 + z2 =x2 + x1

2+

x2 − x1

2= x2

y3 − z3 =x3 + x2

2− x3 − x2

2= x2

y3 + z3 =x3 + x2

2+

x3 − x2

2= x3

......

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 22: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I So we can omit every other row in H, G and still produceenough to be able to recover x

I This is called downsampling.I We are also now in a position to truncate our matrix.

Indeed, if x = (x0, . . . , xN), then it is natural to truncate thematrix and write:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 23: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I So we can omit every other row in H, G and still produceenough to be able to recover x

I This is called downsampling.I We are also now in a position to truncate our matrix.

Indeed, if x = (x0, . . . , xN), then it is natural to truncate thematrix and write:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 24: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I So we can omit every other row in H, G and still produceenough to be able to recover x

I This is called downsampling.I We are also now in a position to truncate our matrix.

Indeed, if x = (x0, . . . , xN), then it is natural to truncate thematrix and write:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 25: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I So we can omit every other row in H, G and still produceenough to be able to recover x

I This is called downsampling.I We are also now in a position to truncate our matrix.

Indeed, if x = (x0, . . . , xN), then it is natural to truncate thematrix and write:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 26: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

W̃N =

12

12 0 0 0 0 0 0

0 0 12

12 0 0 . . . 0 0

.... . .

...0 0 0 0 . . . 0 0 1

212

−12

12 0 0 0 0 0 0

0 0 −12

12 0 0 . . . 0 0

.... . .

...0 0 0 0 . . . 0 0 −1

212

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 27: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

This matrix is easy to invert if we remember the formulas:

xn = yn + zn and xn−1 = yn − zn

We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 28: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

W̃−1N =

1 0 01 0 00 1 00 1 0...

. . ....

0 0 00 0 00 0 10 0 1

∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣

−1 0 01 0 00 −1 00 1 0...

. . ....

0 0 00 0 00 0 −10 0 1

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 29: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Note we are very close to having W̃N an orthogonal matrix.I We have W̃ T

N = 12W̃−1

N .I If we multiply W̃N by

√2, we will obtain an orthogonal

matrix.I We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 30: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Note we are very close to having W̃N an orthogonal matrix.I We have W̃ T

N = 12W̃−1

N .I If we multiply W̃N by

√2, we will obtain an orthogonal

matrix.I We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 31: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Note we are very close to having W̃N an orthogonal matrix.I We have W̃ T

N = 12W̃−1

N .I If we multiply W̃N by

√2, we will obtain an orthogonal

matrix.I We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 32: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Note we are very close to having W̃N an orthogonal matrix.I We have W̃ T

N = 12W̃−1

N .I If we multiply W̃N by

√2, we will obtain an orthogonal

matrix.I We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 33: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I Note we are very close to having W̃N an orthogonal matrix.I We have W̃ T

N = 12W̃−1

N .I If we multiply W̃N by

√2, we will obtain an orthogonal

matrix.I We have:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 34: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

WN =

H

G

=

√2

2

√2

2 0 0 0 00 0

√2

2

√2

2 0 0...

. . ....

0 0 0 0 . . .√

22

√2

2

−√

22

√2

2 0 0 0 00 0 −

√2

2

√2

2 0 0...

. . ....

0 0 0 0 . . . −√

22

√2

2

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 35: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I WN is called the Discrete Haar Wavelet TransformI The filter

h =

(√2

2,

√2

2

)

is called the Haar filter.I Note that H(ω) =

√2

2 +√

22 eiω satisfies H(π) = 0, but

H(0) =√

22 . We will still consider this to be a lowpass filter-

the√

22 resulted when we made the transform orthogonal.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 36: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I WN is called the Discrete Haar Wavelet TransformI The filter

h =

(√2

2,

√2

2

)

is called the Haar filter.I Note that H(ω) =

√2

2 +√

22 eiω satisfies H(π) = 0, but

H(0) =√

22 . We will still consider this to be a lowpass filter-

the√

22 resulted when we made the transform orthogonal.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 37: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I WN is called the Discrete Haar Wavelet TransformI The filter

h =

(√2

2,

√2

2

)

is called the Haar filter.I Note that H(ω) =

√2

2 +√

22 eiω satisfies H(π) = 0, but

H(0) =√

22 . We will still consider this to be a lowpass filter-

the√

22 resulted when we made the transform orthogonal.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 38: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Putting Two Filters Together

Building the Haar MatrixPutting Two Filters Together

I WN is called the Discrete Haar Wavelet TransformI The filter

h =

(√2

2,

√2

2

)

is called the Haar filter.I Note that H(ω) =

√2

2 +√

22 eiω satisfies H(π) = 0, but

H(0) =√

22 . We will still consider this to be a lowpass filter-

the√

22 resulted when we made the transform orthogonal.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 39: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I The word wavelet comes from the more classical treatmentof the topic. Here, we work in L2(R) and downsampling isbasically a way to move between nested subspaces Vj thatare generated by the translates and dilates of a singlescaling function.

I If V0 is the space of piecewise constants with possiblebreaks at Z, then the characteristic function φ(t) = χ[0,1)(t)and its translates form an orthonormal basis for V0.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 40: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I The word wavelet comes from the more classical treatmentof the topic. Here, we work in L2(R) and downsampling isbasically a way to move between nested subspaces Vj thatare generated by the translates and dilates of a singlescaling function.

I If V0 is the space of piecewise constants with possiblebreaks at Z, then the characteristic function φ(t) = χ[0,1)(t)and its translates form an orthonormal basis for V0.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 41: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I The word wavelet comes from the more classical treatmentof the topic. Here, we work in L2(R) and downsampling isbasically a way to move between nested subspaces Vj thatare generated by the translates and dilates of a singlescaling function.

I If V0 is the space of piecewise constants with possiblebreaks at Z, then the characteristic function φ(t) = χ[0,1)(t)and its translates form an orthonormal basis for V0.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 42: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 43: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

If V1 is the space of piecewise constants with possiblebreakpoints at 1

2Z, then V0 ⊂ V1, and the functions√

2φ(2t − k)form an orthornormal basis for V1.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 44: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

Note that

φ(t) =√

2

(√2

2φ(2t) +

√2

2φ(2t − 1)

)

is called a dilation equation.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 45: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I We can get the Haar filter coefficients from the dilationequation.

I The word wavelet refers to the function ψ(t) that generatesa basis for the orthogonal complement of V0 in V1.

I In this case, the wavelet function is

ψ(t) =

{1 0 ≤ t < 1

2−1 1

2 ≤ t < 1

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 46: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I We can get the Haar filter coefficients from the dilationequation.

I The word wavelet refers to the function ψ(t) that generatesa basis for the orthogonal complement of V0 in V1.

I In this case, the wavelet function is

ψ(t) =

{1 0 ≤ t < 1

2−1 1

2 ≤ t < 1

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 47: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I We can get the Haar filter coefficients from the dilationequation.

I The word wavelet refers to the function ψ(t) that generatesa basis for the orthogonal complement of V0 in V1.

I In this case, the wavelet function is

ψ(t) =

{1 0 ≤ t < 1

2−1 1

2 ≤ t < 1

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 48: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I We can get the Haar filter coefficients from the dilationequation.

I The word wavelet refers to the function ψ(t) that generatesa basis for the orthogonal complement of V0 in V1.

I In this case, the wavelet function is

ψ(t) =

{1 0 ≤ t < 1

2−1 1

2 ≤ t < 1

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 49: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

Note that ψ(t) ∈ V1 and

ψ(t) = φ(t) =√

2

(√2

2φ(2t)−

√2

2φ(2t − 1)

)

so that the highpass filter g =(√

22 ,−

√2

2

)can be read from this

dilation equation.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 50: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I I opted to stay away from the classical approach towavelets.

I It is beautiful theory, but too much for sophomores andjuniors.

I I believe it’s better to give them a practical introduction toFourier series and convolution, and then derive the thediscrete wavelet transform by using a lowpass/highpassfilter pair and downsampling.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 51: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I I opted to stay away from the classical approach towavelets.

I It is beautiful theory, but too much for sophomores andjuniors.

I I believe it’s better to give them a practical introduction toFourier series and convolution, and then derive the thediscrete wavelet transform by using a lowpass/highpassfilter pair and downsampling.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 52: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I I opted to stay away from the classical approach towavelets.

I It is beautiful theory, but too much for sophomores andjuniors.

I I believe it’s better to give them a practical introduction toFourier series and convolution, and then derive the thediscrete wavelet transform by using a lowpass/highpassfilter pair and downsampling.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 53: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Why the Word Wavelet?

Building the Haar MatrixWhy the Word Wavelet?

I I opted to stay away from the classical approach towavelets.

I It is beautiful theory, but too much for sophomores andjuniors.

I I believe it’s better to give them a practical introduction toFourier series and convolution, and then derive the thediscrete wavelet transform by using a lowpass/highpassfilter pair and downsampling.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 54: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Examples

Building the Haar MatrixExamples

Let’s have a look at the Mathematica notebook

HaarTransforms1D.nb

for a bit more on Haar Transforms.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 55: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

I The natural inclination when coding the DHWT is to simplywrite a loop and compute the lowpass portion and thehighpass portion in the same loop.

I This bogs down in Mathematica and is also difficult togeneralize when we consider longer filters.

I If we look at the lowpass portion of the transform, Hv, wecan see a better way to code things.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 56: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

I The natural inclination when coding the DHWT is to simplywrite a loop and compute the lowpass portion and thehighpass portion in the same loop.

I This bogs down in Mathematica and is also difficult togeneralize when we consider longer filters.

I If we look at the lowpass portion of the transform, Hv, wecan see a better way to code things.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 57: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

I The natural inclination when coding the DHWT is to simplywrite a loop and compute the lowpass portion and thehighpass portion in the same loop.

I This bogs down in Mathematica and is also difficult togeneralize when we consider longer filters.

I If we look at the lowpass portion of the transform, Hv, wecan see a better way to code things.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 58: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

I The natural inclination when coding the DHWT is to simplywrite a loop and compute the lowpass portion and thehighpass portion in the same loop.

I This bogs down in Mathematica and is also difficult togeneralize when we consider longer filters.

I If we look at the lowpass portion of the transform, Hv, wecan see a better way to code things.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 59: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

Consider Hv when v ∈ R8. We have

Hv =

√2

2

v1 + v2v3 + v4v5 + v6v7 + v8

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 60: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

If we rewrite this, we have

Hv =

√2

2

v1 + v2v3 + v4v5 + v6v7 + v8

=

v1 v2v3 v4v5 v6v7 v8

·[ √

22√2

2

]= Vh

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 61: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

In a similar way we see that

Gv = Vg

So all we need to do to compute Wnv is to create V , multiply itwith h and g, and join to the two blocks together!

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 62: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing WN

Coding the Haar TransformImplementing WN

Here is some Mathematica code to do it:

DHWT[v_]:=Module[{V,lp,hp,y},V=Partition[v,2,2];lp=V.{1,1};hp=V.{1,-1};y=Join[lp,hp];Return[Sqrt[2]*y/2];

];

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 63: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I Writing the code for the inverse transform is a bit trickier.I Now the computation is

W TN v =

[HT∣∣∣ GT

]v

I Let’s again look at a vector v ∈ R8 and consider theproduct W T

8 v:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 64: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I Writing the code for the inverse transform is a bit trickier.I Now the computation is

W TN v =

[HT∣∣∣ GT

]v

I Let’s again look at a vector v ∈ R8 and consider theproduct W T

8 v:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 65: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I Writing the code for the inverse transform is a bit trickier.I Now the computation is

W TN v =

[HT∣∣∣ GT

]v

I Let’s again look at a vector v ∈ R8 and consider theproduct W T

8 v:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 66: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I Writing the code for the inverse transform is a bit trickier.I Now the computation is

W TN v =

[HT∣∣∣ GT

]v

I Let’s again look at a vector v ∈ R8 and consider theproduct W T

8 v:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 67: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

W T8 v =

√2

2

1 0 0 0 −1 0 0 01 0 0 0 1 0 0 00 1 0 0 0 −1 0 00 1 0 0 0 1 0 00 0 1 0 0 0 −1 00 0 1 0 0 0 1 00 0 0 1 0 0 0 −10 0 0 1 0 0 0 1

·

v1v2v3v4v5v6v7v8

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 68: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

or

W T8 v =

√2

2

v1 − v5v1 + v5v2 − v6v2 + v6v3 − v7v3 + v7v4 − v8v4 + v8

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 69: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I The matrix V takes a bit different shape this time.I Now V is

V =

v1 v5v2 v6v3 v7v4 v8

I We need to dot V with both h and g but then intertwine the

results.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 70: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I The matrix V takes a bit different shape this time.I Now V is

V =

v1 v5v2 v6v3 v7v4 v8

I We need to dot V with both h and g but then intertwine the

results.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 71: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I The matrix V takes a bit different shape this time.I Now V is

V =

v1 v5v2 v6v3 v7v4 v8

I We need to dot V with both h and g but then intertwine the

results.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 72: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

I The matrix V takes a bit different shape this time.I Now V is

V =

v1 v5v2 v6v3 v7v4 v8

I We need to dot V with both h and g but then intertwine the

results.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 73: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Implementing W TN

Coding the Haar TransformImplementing W T

N

Let’s return to the Mathematica notebook

HaarTransforms1D.nb

to see how to code the inverse.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 74: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I Let’s now assume A is an N × N image with N even.I How do we transform A?I If we compute WNA, we are simply applying the DHWT to

each column of A:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 75: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I Let’s now assume A is an N × N image with N even.I How do we transform A?I If we compute WNA, we are simply applying the DHWT to

each column of A:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 76: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I Let’s now assume A is an N × N image with N even.I How do we transform A?I If we compute WNA, we are simply applying the DHWT to

each column of A:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 77: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I Let’s now assume A is an N × N image with N even.I How do we transform A?I If we compute WNA, we are simply applying the DHWT to

each column of A:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 78: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

A WNA

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 79: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I We’ve processed the columns of A - what should we do toprocess the rows of A as well?

I Answer: Compute WNAW TN .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 80: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I We’ve processed the columns of A - what should we do toprocess the rows of A as well?

I Answer: Compute WNAW TN .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 81: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I We’ve processed the columns of A - what should we do toprocess the rows of A as well?

I Answer: Compute WNAW TN .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 82: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

A WNAW TN

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 83: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I If we look at WNAW TN in block format, we can get a better

idea what’s going on.I

WNAW TN =

[HG

]A[

HG

]T

=

[HAGA

] [HT GT

]=

[HAHT HAGT

GAHT GAGT

]

=

[B VH D

]

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 84: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I If we look at WNAW TN in block format, we can get a better

idea what’s going on.I

WNAW TN =

[HG

]A[

HG

]T

=

[HAGA

] [HT GT

]=

[HAHT HAGT

GAHT GAGT

]

=

[B VH D

]

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 85: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I If we look at WNAW TN in block format, we can get a better

idea what’s going on.I

WNAW TN =

[HG

]A[

HG

]T

=

[HAGA

] [HT GT

]=

[HAHT HAGT

GAHT GAGT

]

=

[B VH D

]

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 86: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I HAHT averages along the columns of A and then along therows of HA. This will produce an approximation (or blur) Bof A.

I HAGT averages along the columns of A and thendifferences along the rows of HA. This will produce verticaldifferences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 87: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I HAHT averages along the columns of A and then along therows of HA. This will produce an approximation (or blur) Bof A.

I HAGT averages along the columns of A and thendifferences along the rows of HA. This will produce verticaldifferences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 88: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I HAHT averages along the columns of A and then along therows of HA. This will produce an approximation (or blur) Bof A.

I HAGT averages along the columns of A and thendifferences along the rows of HA. This will produce verticaldifferences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 89: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I GAHT differences along the columns of A and thenaverages along the rows of GA. This will producehorizontal differences H between B and A.

I GAGT differences along the columns of A and thendifferences along the rows of GA. This will producediagonal differences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 90: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I GAHT differences along the columns of A and thenaverages along the rows of GA. This will producehorizontal differences H between B and A.

I GAGT differences along the columns of A and thendifferences along the rows of GA. This will producediagonal differences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 91: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

I GAHT differences along the columns of A and thenaverages along the rows of GA. This will producehorizontal differences H between B and A.

I GAGT differences along the columns of A and thendifferences along the rows of GA. This will producediagonal differences V between B and A.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 92: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Building the 2D Transform

2D Haar TransformBuilding the 2D Transform

To better understand these block forms, let’s look at theMathematica notebook

HaarTransforms2D.nb

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 93: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I Coding the 2D Haar transform is easy - we already have aroutine that will apply the DHWT to each column of A,

I so we can easily write a routine to compute C = WNA.Let’s call this routine W.

I Our goal is to compute B = WNAW TN = CW T

N .I It turns out that writing code for CW T

N is a bit tedious, but ifwe use some linear algebra . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 94: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I Coding the 2D Haar transform is easy - we already have aroutine that will apply the DHWT to each column of A,

I so we can easily write a routine to compute C = WNA.Let’s call this routine W.

I Our goal is to compute B = WNAW TN = CW T

N .I It turns out that writing code for CW T

N is a bit tedious, but ifwe use some linear algebra . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 95: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I Coding the 2D Haar transform is easy - we already have aroutine that will apply the DHWT to each column of A,

I so we can easily write a routine to compute C = WNA.Let’s call this routine W.

I Our goal is to compute B = WNAW TN = CW T

N .I It turns out that writing code for CW T

N is a bit tedious, but ifwe use some linear algebra . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 96: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I Coding the 2D Haar transform is easy - we already have aroutine that will apply the DHWT to each column of A,

I so we can easily write a routine to compute C = WNA.Let’s call this routine W.

I Our goal is to compute B = WNAW TN = CW T

N .I It turns out that writing code for CW T

N is a bit tedious, but ifwe use some linear algebra . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 97: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I Coding the 2D Haar transform is easy - we already have aroutine that will apply the DHWT to each column of A,

I so we can easily write a routine to compute C = WNA.Let’s call this routine W.

I Our goal is to compute B = WNAW TN = CW T

N .I It turns out that writing code for CW T

N is a bit tedious, but ifwe use some linear algebra . . .

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 98: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I If we transpose both sides of B = CW TN , we have

BT = WNCT

I So we can simply apply W to CT and transpose the result.I One student wasn’t so sure about this . . .I Let’s return to HaarTransforms2D.nb to write some

code for the 2D Haar Wavelet Transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 99: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I If we transpose both sides of B = CW TN , we have

BT = WNCT

I So we can simply apply W to CT and transpose the result.I One student wasn’t so sure about this . . .I Let’s return to HaarTransforms2D.nb to write some

code for the 2D Haar Wavelet Transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 100: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I If we transpose both sides of B = CW TN , we have

BT = WNCT

I So we can simply apply W to CT and transpose the result.I One student wasn’t so sure about this . . .I Let’s return to HaarTransforms2D.nb to write some

code for the 2D Haar Wavelet Transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 101: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I If we transpose both sides of B = CW TN , we have

BT = WNCT

I So we can simply apply W to CT and transpose the result.I One student wasn’t so sure about this . . .I Let’s return to HaarTransforms2D.nb to write some

code for the 2D Haar Wavelet Transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 102: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Coding the 2D Transform

2D Haar TransformCoding the 2D Transform

I If we transpose both sides of B = CW TN , we have

BT = WNCT

I So we can simply apply W to CT and transpose the result.I One student wasn’t so sure about this . . .I Let’s return to HaarTransforms2D.nb to write some

code for the 2D Haar Wavelet Transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 103: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I It’s time to explain the NumIterations directive you haveseen in the Mathematica notebooks.

I We can motivate the idea by looking at the cumulativeenergy of an image A and its wavelet transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 104: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I It’s time to explain the NumIterations directive you haveseen in the Mathematica notebooks.

I We can motivate the idea by looking at the cumulativeenergy of an image A and its wavelet transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 105: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I It’s time to explain the NumIterations directive you haveseen in the Mathematica notebooks.

I We can motivate the idea by looking at the cumulativeenergy of an image A and its wavelet transform.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 106: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

Here is a 200× 200 image and it’s transform:

A WNAW TN

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 107: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

Here are the cumulative energies for both A (red) and itstransform (brown):

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 108: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I To give you an idea, the largest 10000 elements in A makeup about 36.5% of the energy in A while the first 10000elements in the transform comprise about 99.5% of theenergy in the transform.

I The wavelet transform is totally invertible, so if we were toHuffman encode the transform, the bit stream should bemarkedly smaller.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 109: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I To give you an idea, the largest 10000 elements in A makeup about 36.5% of the energy in A while the first 10000elements in the transform comprise about 99.5% of theenergy in the transform.

I The wavelet transform is totally invertible, so if we were toHuffman encode the transform, the bit stream should bemarkedly smaller.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 110: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I To give you an idea, the largest 10000 elements in A makeup about 36.5% of the energy in A while the first 10000elements in the transform comprise about 99.5% of theenergy in the transform.

I The wavelet transform is totally invertible, so if we were toHuffman encode the transform, the bit stream should bemarkedly smaller.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 111: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I We can get even more concentration of the energy if weiterate the wavelet transform. That is, after computing thewavelet transform of A, we extract the blur and compute awavelet transform of it.

I We could repeat this process p times if the dimensions ofA are divisible by 2p.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 112: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I We can get even more concentration of the energy if weiterate the wavelet transform. That is, after computing thewavelet transform of A, we extract the blur and compute awavelet transform of it.

I We could repeat this process p times if the dimensions ofA are divisible by 2p.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 113: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

I We can get even more concentration of the energy if weiterate the wavelet transform. That is, after computing thewavelet transform of A, we extract the blur and compute awavelet transform of it.

I We could repeat this process p times if the dimensions ofA are divisible by 2p.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 114: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

Now suppose we iterate 2 times:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 115: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

or 3 times:

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 116: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

2D Haar TransformIterating

Here are the cumulative energy vectors for 1 iteration (brown),2 iterations (blue), and 3 iterations (gray):

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 117: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Teaching Ideas

In the ClassroomTeaching Ideas

I The students really enjoy the material in this chapter. It isquite straightforward and ties together everything newwe’ve done to date.

I I have them look at the entropy of particular vectors whenprocessed by the Haar transform. This gives them someidea of the potential for wavelet-based compression.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 118: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Teaching Ideas

In the ClassroomTeaching Ideas

I The students really enjoy the material in this chapter. It isquite straightforward and ties together everything newwe’ve done to date.

I I have them look at the entropy of particular vectors whenprocessed by the Haar transform. This gives them someidea of the potential for wavelet-based compression.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 119: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Teaching Ideas

In the ClassroomTeaching Ideas

I The students really enjoy the material in this chapter. It isquite straightforward and ties together everything newwe’ve done to date.

I I have them look at the entropy of particular vectors whenprocessed by the Haar transform. This gives them someidea of the potential for wavelet-based compression.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 120: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I As you might imagine, we do lots of coding in this chapter.I I let the students work in pairs and they write code for the

Haar transform and its inverse (1D and 2D) as well asiterated versions.

I They can get pretty frustrated with Mathematica at thispoint - it is good to show them some simple debuggingtechniques.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 121: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I As you might imagine, we do lots of coding in this chapter.I I let the students work in pairs and they write code for the

Haar transform and its inverse (1D and 2D) as well asiterated versions.

I They can get pretty frustrated with Mathematica at thispoint - it is good to show them some simple debuggingtechniques.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 122: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I As you might imagine, we do lots of coding in this chapter.I I let the students work in pairs and they write code for the

Haar transform and its inverse (1D and 2D) as well asiterated versions.

I They can get pretty frustrated with Mathematica at thispoint - it is good to show them some simple debuggingtechniques.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 123: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I As you might imagine, we do lots of coding in this chapter.I I let the students work in pairs and they write code for the

Haar transform and its inverse (1D and 2D) as well asiterated versions.

I They can get pretty frustrated with Mathematica at thispoint - it is good to show them some simple debuggingtechniques.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 124: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I I let them use their own images/audio files (sometimesdangerous).

I To test their iterated 1D inverse, they must download anaudio clip from my website that has been transformed ptimes, guess at p, and then apply their inverse to guess themovie clip.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 125: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I I let them use their own images/audio files (sometimesdangerous).

I To test their iterated 1D inverse, they must download anaudio clip from my website that has been transformed ptimes, guess at p, and then apply their inverse to guess themovie clip.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 126: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Computer Usage

In the ClassroomComputer Usage

I I let them use their own images/audio files (sometimesdangerous).

I To test their iterated 1D inverse, they must download anaudio clip from my website that has been transformed ptimes, guess at p, and then apply their inverse to guess themovie clip.

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms

Page 127: Discrete Haar Wavelet Transforms - University of St. Thomaspersonal.stthomas.edu/pjvanfleet/wavelets/pdffiles/UST2006/Lecture... · Today’s Schedule Building the Haar Matrix Coding

Today’s Schedule Building the Haar Matrix Coding the Haar Transform 2D Haar Transform Iterating In the Classroom

Today’s Schedule

9:00-10:15 Lecture One: Why Wavelets?10:15-10:30 Coffee Break (OSS 235)10:30-11:45 Lecture Two: Digital Images, Measures, and

Huffman Codes12:00-1:00 Lunch (Cafeteria)1:30-2:45 Lecture Three: Fourier Series, Convolution and

Filters2:45-3:00 Coffee Break (OSS 235)3:00-4:15 Lecture Four: 1D and 2D Haar Transforms5:30-6:30 ⇒Dinner (Cafeteria)

Wednesday, 7 June, 2006 Lecture 4

Discrete Haar Wavelet Transforms