Haar Wavelets ...a continuation of Part II

Consider the sequence of grey squares:

The numbers represent the shade of grey, with larger numbers being closer to white and smaller numbers closer to black.

>Are we still talking stock prices?
Uh ... no, we're digressing.
Remember that Haar wavelets provide a mechanism for decomposing a sequence of numbers (like stock prices) into components that give a coarse (or smooth) description of the number sequence and a collection of finer detail. The smooth component is a kind of averaging. The wavelets will allow us to compress the amount of information in the number sequence ... without losing all the detail.
In fact, a most interesting application of such wavelets is in storing picture information and ...

>Huh?
The sequence of grey squares, above, might be a line of pixels in a monochrome picture, like so:

This line of pixels is stored digitally as a sequence of numbers: 120, 160, 200, 210, 240, 210, 150, 120.
Now suppose we average each successive pair of numbers to get: (120+160)/2 = 140, (200+210)/2 = 205, (240+210)/2 = 225, (150+120)/2 = 135.
See? We've halved the number of numbers from 8 to 4. We could display our modified pixels in pairs: 140,140,205,205,225,225,135,135.
>Yeah, clever, but if that were a picture of me you'd probably lose my fine features
You DO remember my fine features, don't you?

Aah, yes, your fine features. That's where those differences come in. Remember that we calculated differences between successive numbers, as well as averages?
Those differences allow us to recontruct the original numbers ... if we choose to do so.
However, this compression technique (using wavelets) does a remarkable job of retaining the essential features of the original numbers (meaning, in our case, the original picture).
Indeed, the compression technique called JPEG 2000 uses wavelets. There's a neat demo here, comparing JPEG and the newer JPEG2000.
>JPEG?
Yes, the Joint Photographic Experts Group.
I use a lot of pictures in JPEG format, for example this one, on a camping trip.
If I were to store pictures with every single pixel retained in its original state (without compression)
they could be five or ten times larger ... and look no better, in small sizes.

>And JPEG 2000 compression? Do you use that?
Uh ... not yet.
I might point out that the older JPEG uses a compression technique that's based upon ... are ready for this? Fourier series.


Grand Tetons
>But maybe I'd like to retain ALL the detail and I don't worry about the mamory required to store the pciture. Suppose I ...
Then you can save your picture as a bitmap picture.

.BMP image

.JPEG image
>I see the difference. It's quite clear that the bitmap has more detail.
  I'm surprised that you can't see the difference and ...

  I thought you'd say that, so I stuck the JPEG on the left and the BMP on the right.
  To see how large the image is (in terms of memory space)
  right-click each picture and ask for image properties.

Look at the picture of the Grand Tetons. This is the front of our motorhome, in colour     and in 256 shades of grey     and in 16 shades of grey  
Up close they look like this
Note all the repetition in the shades of grey.

>And that's wavelet compression?
That's JPEG compression ... the older version of JPEG based upon Fourier stuff.
It's pretty good, eh?

>So why would anyone want to compress a sequence of stock prices?
Wavelets aren't used to compress, but to pick out the salient features of stock prices (or returns), separating out the "noise" from the "trends", the wheat from the chaff, the ...

>And the noise is due to day traders, eh?
If you say so.


256 shades of grey

16 shades of grey