lift::haar Class Reference

Inheritance diagram for lift::haar:

Inheritance graph
[legend]
Collaboration diagram for lift::haar:

Collaboration graph
[legend]
List of all members.

Protected Member Functions

void predict (double[] vec, int N, int direction)
void update (double[] vec, int N, int direction)

Detailed Description

Haar (flat line) wavelet.

As with all Lifting scheme wavelet transform functions, the first stage of a transform step is the split stage. The split step moves the even element to the first half of an N element region and the odd elements to the second half of the N element region.

The Lifting Scheme version of the Haar transform uses a wavelet function (predict stage) that "predicts" that an odd element will have the same value as it preceeding even element. Stated another way, the odd element is "predicted" to be on a flat (zero slope line) shared with the even point. The difference between this "prediction" and the actual odd value replaces the odd element.

The wavelet scaling function (a.k.a. smoothing function) used in the update stage calculates the average between an even and an odd element.

The merge stage at the end of the inverse transform interleaves odd and even elements from the two halves of the array (e.g., ordering them even0, odd0, even1, odd1, ...)

Copyright and Use

You may use this source code without limitation and without fee as long as you include: <blockquote> This software was written and is copyrighted by Ian Kaplan, Bear Products International, www.bearcave.com, 2001. </blockquote>

This software is provided "as is", without any warrenty or claim as to its usefulness. Anyone who uses this source code uses it at their own risk. Nor is any support provided by Ian Kaplan and Bear Products International.

Please send any bug fixes or suggested source changes to:

     iank@bearcave.com

Author:
Ian Kaplan


Member Function Documentation

void lift::haar::predict double[]  vec,
int  N,
int  direction
[inline, protected, virtual]
 

Haar predict step

Implements lift::liftbase.

00072   {
00073     int half = N >> 1;
00074     int cnt = 0;
00075 
00076     for (int i = 0; i < half; i++) {
00077       double predictVal = vec[i];
00078       int j = i + half;
00079 
00080       if (direction == forward) {
00081         vec[j] = vec[j] - predictVal;
00082       }
00083       else if (direction == inverse) {
00084         vec[j] = vec[j] + predictVal;
00085       }
00086       else {
00087         System.out.println("haar::predict: bad direction value");
00088       }
00089     }
00090   }

void lift::haar::update double[]  vec,
int  N,
int  direction
[inline, protected, virtual]
 

Update step of the Haar wavelet transform.

The wavelet transform calculates a set of detail or difference coefficients in the predict step. These are stored in the upper half of the array. The update step calculates an average from the even-odd element pairs. The averages will replace the even elements in the lower half of the array.

The Haar wavelet calculation used in the Lifting Scheme is

       dj+1, i = oddj+1, i = oddj, i - evenj, i
       aj+1, i = evenj, i = (evenj, i + oddj, i)/2
    

Note that the Lifting Scheme uses an in-place algorithm. The odd elements have been replaced by the detail coefficients in the predict step. With a little algebra we can substitute the coefficient calculation into the average calculation, which gives us

       aj+1, i = evenj, i = evenj, i + (oddj, i/2)
    

Implements lift::liftbase.

00125   {
00126     int half = N >> 1;
00127 
00128     for (int i = 0; i < half; i++) {
00129       int j = i + half;
00130       double updateVal = vec[j] / 2.0;
00131 
00132       if (direction == forward) {
00133         vec[i] = vec[i] + updateVal;
00134       }
00135       else if (direction == inverse) {
00136         vec[i] = vec[i] - updateVal;
00137       }
00138       else {
00139         System.out.println("update: bad direction value");
00140       }
00141     }
00142   }


The documentation for this class was generated from the following file:
Generated on Sun Dec 11 20:01:09 2005 for LiftingScheme by  doxygen 1.4.5