Haar wavelet example.
Initial
16 12 4 8
8 12 4 16
4 16 8 12
12 8 16 4
Reduce rows
14 2 6 -2
10 -2 10 -6
10 -6 10 -2
10 2 10 6
Reduce cols
12 0 8 -4
2 2 -2 2
10 -2 10 2
0 -4 0 -4
Juggled Pixels
12 8 0 -4
10 10 -2 2
2 -2 2 2
0 0 -4 -4
Reduce rows
10 2
10 0
Reduce cols
10 1
0 1
Juggled Pixels
10 1
0 1
Result of Haar on Submatrix
10 1
0 1
Result of Haar on Submatrix
10 1 0 -4
0 1 -2 2
2 -2 2 2
0 0 -4 -4
Notes
- Note: loss of information (if all calculations done with integers)...
0 0 -> 0 0
1 0 -> 0 1 (assumes integer values computed at each step)
that is
1 0 -> (int)((1+0)/2) 1-(int)((1+0)/2)
performing floating point calculations and then rounding
at the end presents similar problems.
1 1 -> 1 0
1 2 -> 1 0
- Note: To invert the transform you will need to keep some extra bits around. Each time
you 1/2 the image, you multiply the pixels by 1/4. Question:
how many extra bits should we keep to be able to invert the transform?
- Question: Even with extra bits from above, is it possible for
the transform to exceede the range of pixel values? Yes, note the negative numbers in the above example!!
- Question: Could it get worse than that? That is, if all pixel values
are between 0 and 255, can the Haar transorm result in pixel values outside the range
-255, 255? Hint: Consider the 1-d transform.
a b -> (a+b)/2 a-(a+b)/2
a b -> (a+b)/2 (a-b)/2
We will help you with your assignment