lift::haarpoly Class Reference

Inheritance diagram for lift::haarpoly:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 haarpoly ()
void forwardTrans (double[] vec)
void inverseTrans (double[] vec)

Protected Member Functions

void interp (double[] vec, int N, int direction)

Static Package Attributes

static final int numPts = 4

Detailed Description

Haar transform extended with a polynomial interpolation step

This wavelet transform extends the Haar transform with a polynomial wavelet function.

The polynomial wavelet uses 4-point polynomial interpolation to "predict" an odd point from four even point values.

This class extends the Haar transform with an interpolation stage which follows the predict and update stages of the Haar transform. The predict value is calculated from the even points, which in this case are the smoothed values calculated by the scaling function (e.g., the averages of the even and odd values).

The predict value is subtracted from the current odd value, which is the result of the Haar wavelet function (e.g., the difference between the odd value and the even value). This tends to result in large odd values after the interpolation stage, which is a weakness in this algorithm.

This algorithm was suggested by Wim Sweldens' tutorial Building Your Own Wavelets at Home.

  
  http://www.bearcave.com/misl/misl_tech/wavelets/lifting/index.html
  

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


Constructor & Destructor Documentation

lift::haarpoly::haarpoly  )  [inline]
 

haarpoly class constructor

00079   {
00080     fourPt = new polyinterp();
00081   }


Member Function Documentation

void lift::haarpoly::forwardTrans double[]  vec  )  [inline]
 

Haar transform extened with polynomial interpolation forward transform.

This version of the forwardTrans function overrides the function in the liftbase base class. This function introduces an extra polynomial interpolation stage at the end of the transform.

Reimplemented from lift::liftbase.

00209   {
00210     final int N = vec.length;
00211 
00212     for (int n = N; n > 1; n = n >> 1) {
00213       split( vec, n );
00214       predict( vec, n, forward );
00215       update( vec, n, forward );
00216       interp( vec, n, forward );
00217     } // for
00218   } // forwardTrans

void lift::haarpoly::interp double[]  vec,
int  N,
int  direction
[inline, protected]
 

Predict an odd point from the even points, using 4-point polynomial interpolation.

The four points used in the polynomial interpolation are the even points. We pretend that these four points are located at the x-coordinates 0,1,2,3. The first odd point interpolated will be located between the first and second even point, at 0.5. The next N-3 points are located at 1.5 (in the middle of the four points). The last two points are located at 2.5 and 3.5. For complete documentation see

  
  http://www.bearcave.com/misl/misl_tech/wavelets/lifting/index.html
    

The difference between the predicted (interpolated) value and the actual odd value replaces the odd value in the forward transform.

As the recursive steps proceed, N will eventually be 4 and then 2. When N = 4, linear interpolation is used. When N = 2, Haar interpolation is used (the prediction for the odd value is that it is equal to the even value).

Parameters:
vec the input data on which the forward or inverse transform is calculated.
N the area of vec over which the transform is calculated
direction forward or inverse transform
00151   {
00152     int half = N >> 1;
00153     double d[] = new double[ numPts ];
00154 
00155     int k = 42;
00156 
00157     for (int i = 0; i < half; i++) {
00158       double predictVal;
00159 
00160       if (i == 0) {
00161         if (half == 1) {
00162           // e.g., N == 2, and we use Haar interpolation
00163           predictVal = vec[0];
00164         }
00165         else {
00166           fill( vec, d, N, 0 );
00167           predictVal = fourPt.interpPoint( 0.5, half, d );
00168         }
00169       }
00170       else if (i == 1) {
00171         predictVal = fourPt.interpPoint( 1.5, half, d );
00172       }
00173       else if (i == half-2) {
00174         predictVal = fourPt.interpPoint( 2.5, half, d );
00175       }
00176       else if (i == half-1) {
00177         predictVal = fourPt.interpPoint( 3.5, half, d );
00178       }
00179       else {
00180         fill( vec, d, N, i-1);
00181         predictVal = fourPt.interpPoint( 1.5, half, d );
00182       }
00183 
00184       int j = i + half;
00185       if (direction == forward) {
00186         vec[j] = vec[j] - predictVal;
00187       }
00188       else if (direction == inverse) {
00189         vec[j] = vec[j] + predictVal;
00190       }
00191       else {
00192         System.out.println("poly::predict: bad direction value");
00193       }
00194     }
00195   } // interp

void lift::haarpoly::inverseTrans double[]  vec  )  [inline]
 

Haar transform extened with polynomial interpolation inverse transform.

This version of the inverseTrans function overrides the function in the liftbase base class. This function introduces an inverse polynomial interpolation stage at the start of the inverse transform.

Reimplemented from lift::liftbase.

00233    {
00234      final int N = vec.length;
00235 
00236      for (int n = 2; n <= N; n = n << 1) {
00237        interp( vec, n, inverse );
00238        update( vec, n, inverse );
00239        predict( vec, n, inverse );
00240        merge( vec, n );
00241      }
00242    } // inverseTrans


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