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:
and to invert:
To show more clearly what is happening:
If
x=(
ab
cd
)
x
a
b
c
d
then
y=12(
a+b+c+da−b+c−d
a+b−c−da−b−c+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:
a−b+c−d
a
b
c
d
= Average horizontal gradient or horizontal
highpass and vertical lowpass (Hi-Lo) filter.
-
Lower left:
a+b−c−d
a
b
c
d
= Average vertical gradient or
horizontal lowpass and vertical highpass (Lo-Hi) filter.
-
Lower right:
a−b−c+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.