Protected Member Functions  
void  predict (double[] vec, int N, int direction) 
void  update (double[] vec, int N, int direction) 
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 even_{0}, odd_{0}, even_{1}, odd_{1}, ...)
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

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 }


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 evenodd 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 d_{j+1, i} = odd_{j+1, i} = odd_{j, i}  even_{j, i} a_{j+1, i} = even_{j, i} = (even_{j, i} + odd_{j, i})/2 Note that the Lifting Scheme uses an inplace 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 a_{j+1, i} = even_{j, i} = even_{j, i} + (odd_{j, 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 }
