template <typename TYPE>
class Haar { public: char *get_filter_name(); void even_analyze(TYPE *signal, TYPE *low, TYPE *high, int n); void odd_analyze(TYPE *signal, TYPE *low, TYPE *high, int n); void even_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n); void odd_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n); }; template <typename TYPE> char *Haar<TYPE>::get_filter_name() { return "2/1 (Haar) Biorthogonal Perfect Reconstruction Filter Bank"; } template <typename TYPE> void Haar<TYPE>::even_analyze(TYPE *signal, TYPE *low, TYPE *high, int n) { int i, k; for (i = k = 0; k < n; i++, k += 2) { high[i] = signal[k+1] - signal[k]; low[i] = signal[k] + high[i]/2; } } template <typename TYPE> void Haar<TYPE>::even_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n) { int i, k; for (i = k = 0; k < n; i++, k += 2) { signal[k] = low[i] - high[i]/2; signal[k+1] = signal[k] + high[i]; } } template <typename TYPE> void Haar<TYPE>::odd_analyze(TYPE *signal, TYPE *low, TYPE *high, int n) { int i, k; for (i = k = 0; k < (n-1); i++, k += 2) { high[i] = signal[k+1] - signal[k]; low[i] = signal[k] + high[i]/2; } low[i] = signal[k]; } template <typename TYPE> void Haar<TYPE>::odd_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n) { int i, k; for (i = k = 0; k < (n-1); i++, k += 2) { signal[k] = low[i] - high[i]/2; signal[k+1] = signal[k] + high[i]; } signal[k] = low[i]; } |