Saturday, June 24, 2006 |
|
|
Saturday, June 24, 2006
9:52 AM
In
my posts "15 Exercises to Know a Programming Language," I suggested
some exercises investigating the Haar wavelet, the simplest wavelet. I intended
to leave it as is so that people could discover this fascinating subject on
their own, but a couple of questions I've received have made it impossible for
me to hold my tongue.
Okay,
to review: The Haar transform works by transforming an array of values into an
array of average and differences-from-the-average. Thus, [8, 4] becomes [6, 2],
since (8 + 4) / 2 = 6 and 8 - (8 + 4) / 2 = 2. Similarly, [8, 4, 3, 9] becomes,
first, [6, 6, 2, -3] (1st and 3rd positions as per previous, 2nd and 4th same
transform applied to 3 and 9).
What
happens when you apply this transform to a real-world signal? For instance, a
photo. The left of Figure 1 shows "Lena" in lovely 256x256 grayscale.
The right of the figure is a visualization of the very first step of the Haar
transform. Cool, huh?


The
upper-left-most 64x64 block is now a quarter-resolution image of the original.
That makes sense, since it's the average of the previously-created average. Now
consider the 64x64 blocks as we move across (or down). First, we have the
average of the edge-map: a low-resolution version of the 2-pixel scale edge
map. The third block is edge-map of the average and the fourth block is an
edge-map of the edge-map: hey! We're gathering data at different resolutions!
Okay,
let's quickly revisit the fact that by scaling and clipping we're losing data,
but if we just view this is a visualization of an underlying 256 x 256 array,
notice how the "significant" data seems to be moving towards the
edges: the upper-left (low-resolution version of the whole) is still
recognizable, and in the lower-right (the both-directions edge-map of the
edge-map) the data is becoming more chaotic: more "static-y." But in
the middle we're creating a large area with large swaths of gray (I'm even
stretching the grayscale so that there's at least one 0 and one 255 pixel). In
other words, large areas where the real data are tending towards 0. If we fully
recurse, what do we have?

The
upper-left pixel is now the average grayscale value of the entire picture: the
ultimate low-resolution version. The rest of the data can't be parsed by our
eyes, but is easily compressed. Now, if you're really building a wavelet
compressor, you don't scale and clip (as
we did for this), but you clip when detail coefficients go below some epsilon.
By experimenting with epsilon (making it dynamic?) you can get some very, very
impressive compression results.
Some
other interesting things to do with wavelets are scale the detail coefficients up and reconstruct the signal: this amplifies
low-contrast aspects of the original. Implications of that are left as an
exercise to those interested in steganography and forensics.
Wavelets
can also be used to aide pattern recognition in signals, since minor variations
"move" towards the detail coefficients.
Oh,
and you should try wavelet processing on sound. Equally fascinating stuff.
Created with Microsoft Office OneNote 2007 (Beta)
One place for all your information
Download: The Haar Transform.one
|
|
|
|
|
|
|
|
| Recently Published Articles |
|
|
|
|
|
|
|
| HI |
|
|
|
|
| Archive |
| June, 2008 (3) |
| May, 2008 (1) |
| April, 2008 (11) |
| March, 2008 (11) |
| February, 2008 (24) |
| January, 2008 (20) |
| December, 2007 (18) |
| November, 2007 (25) |
| October, 2007 (27) |
| September, 2007 (16) |
| August, 2007 (28) |
| July, 2007 (46) |
| June, 2007 (41) |
| May, 2007 (23) |
| April, 2007 (26) |
| March, 2007 (23) |
| February, 2007 (27) |
| January, 2007 (36) |
| December, 2006 (31) |
| November, 2006 (24) |
| October, 2006 (36) |
| September, 2006 (52) |
| August, 2006 (56) |
| July, 2006 (34) |
| June, 2006 (63) |
| May, 2006 (45) |
| April, 2006 (29) |
| March, 2006 (30) |
| February, 2006 (17) |
| January, 2006 (11) |
| December, 2005 (27) |
| November, 2005 (8) |
| October, 2005 (21) |
| September, 2005 (48) |
| August, 2005 (14) |
| July, 2005 (17) |
| June, 2005 (8) |
| May, 2005 (10) |
| April, 2005 (10) |
| March, 2005 (43) |
| February, 2005 (21) |
| January, 2005 (22) |
| December, 2004 (69) |
| November, 2004 (46) |
| October, 2004 (28) |
| September, 2004 (8) |
| August, 2004 (5) |
| July, 2004 (1) |
| June, 2004 (27) |
| May, 2004 (12) |
| April, 2004 (45) |
| March, 2004 (89) |
| February, 2004 (37) |
| January, 2004 (10) |
| December, 2003 (42) |
| November, 2003 (52) |
| October, 2003 (32) |
| September, 2003 (16) |
| August, 2003 (20) |
| July, 2003 (20) |
| June, 2003 (26) |
| May, 2003 (20) |
| April, 2003 (3) |
| March, 2003 (1) |
| February, 2003 (11) |
| January, 2003 (16) |
| December, 2002 (23) |
| November, 2002 (26) |
| October, 2002 (38) |
| September, 2002 (55) |
| August, 2002 (4) |
| July, 2002 (3) |
| June, 2002 (3) |
|
|
|
|