# Connexions

You are here: Home » Content » The Haar Transform

### Recently Viewed

This feature requires Javascript to be enabled.

# The Haar Transform

Module by: Nick Kingsbury. E-mail the author

Summary: This module introduces the Haar transform.

Note: You are viewing an old version of this document. The latest version is available here.

Probably the simplest useful energy compression process is the Haar transform. In 1-dimension, this transforms a 2-element vector ( x1x2 )T x 1 x 2 into ( y1y2 )T y 1 y 2 using:

y1y2=Tx1x2 y 1 y 2 T x 1 x 2
(1)
where T=12( 11 1-1 ) T 1 2 1 1 1 -1 . Thus y1 y 1 and y2 y 2 are simply the sum and difference of x1 x 1 and x2 x 2 , scaled by 12 1 2 to preserve energy.

Note that TT is an orthonormal matrix because its rows are orthogonal to each other (their dot products are zero) and they are normalized to unit magnitude. Therefore T-1=TT T T . (In this case TT is symmetric so TT=T T T .) Hence we may recover xx from yy using:

x1x2=TTy1y2 x 1 x 2 T y 1 y 2
(2)
In 2-dimensions xx and yy become 2×2 2 2 matrices. We may transform first the columns of xx, by premultiplying by TT, and then the rows of the result by postmultiplying by TT T . Hence:
y=TxTT y T x T
(3)
and to invert:
x=TTyT x T y T
(4)

If x=( ab cd ) x a b c d then y=12( a+b+c+dab+cd a+bcdabc+d ) y 1 2 a b c d a b c d a b c d a b c d These operations correspond to the following filtering processes:

• Top left: a+b+c+d a b c d = 4-point average or 2-D lowpass (Lo-Lo) filter.
• Top right: ab+cd a b c d = Average horizontal gradient or horizontal highpass and vertical lowpass (Hi-Lo) filter.
• Lower left: a+bcd a b c d = Average vertical gradient or horizontal lowpass and vertical highpass (Lo-Hi) filter.
• Lower right: abc+d a b c d = Diagonal curvature or 2-D highpass (Hi-Hi) filter.
To apply this transform to a complete image, we group the pels into 2×2 2 2 blocks and apply Equation 3 to each block. The result (after reordering) is shown in Figure 1(b). To view the result sensibly, we have grouped all the top left components of the 2×2 2 2 blocks in yy together to form the top left subimage in Figure 1(b), and done the same for the components in the other 3 positions to form the corresponding other 3 subimages.

It is clear from Figure 1(b) that most of the energy is contained in the top left (Lo-Lo) subimage and the least energy is in the lower right (Hi-Hi) subimage. Note how the top right (Hi-Lo) subimage contains the near-vertical edges and the lower left (Lo-Hi) subimage contains the near-horizontal edges.

The energies of the subimages and their percentages of the total are:

Table 1
Lo-Lo Hi-Lo Lo-Hi Hi-Hi
201.73×106 201.73 10 6 4.56×106 4.56 10 6 1.89×106 1.89 10 6 0.82×106 0.82 10 6
96.5% 2.2% 0.9% 0.4%

Total energy in Figure 1(a) and Figure 1(b) = 208.99×106 208.99 10 6 .

We see that a significant compression of energy into the Lo-Lo subimage has been achieved. However the energy measurements do not tell us directly how much data compression this gives.

A much more useful measure than energy is the entropy of the subimages after a given amount of quantization. This gives the minimum number of bits per pel needed to represent the quantized data for each subimage, to a given accuracy, assuming that we use an ideal entropy code. By comparing the total entropy of the 4 subimages with that of the original image, we can estimate the compression that one level of the Haar transform can provide.

## Content actions

### Give feedback:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks