template <typename TYPE>
class _5_3 { 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 *_5_3<TYPE>::get_filter_name() { return "5/3 (Lineal) Biorthogonal Perfect Reconstruction Filter Bank"; } template <typename TYPE> void _5_3<TYPE>::even_analyze(TYPE *signal, TYPE *low, TYPE *high, int n) { int i; for(i=0;i<n/2-1;i++) { int i2 = i<<1; //high[i] = signal[i2+1] - ((signal[i2]+signal[i2+2])>>1); high[i] = signal[i2+1] - (signal[i2]+signal[i2+2])/2; } high[i] = signal[n-1] - signal[n-2]; //low[0] = signal[0] + ((high[0]+1)>>1); low[0] = signal[0] + high[0]/2; for(i=1;i<n/2;i++) { int i2 = i<<1; //low[i] = signal[i2] + ((high[i]+high[i-1]+2)>>2); low[i] = signal[i2] + (high[i]+high[i-1])/4; } } template <typename TYPE> void _5_3<TYPE>::even_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n) { int i; //signal[0] = low[0] - ((high[0]+1)>>1); signal[0] = low[0] - high[0]/2; for(i=1;i<n/2;i++) { int i2 = i<<1; //signal[i2] = low[i] - ((high[i]+high[i-1]+2)>>2); signal[i2] = low[i] - (high[i]+high[i-1])/4; } for(i=0;i<n/2-1;i++) { int i2 = i<<1; //signal[i2+1] = high[i] + ((signal[i2]+signal[i2+2])>>1); signal[i2+1] = high[i] + (signal[i2]+signal[i2+2])/2; } signal[n-1] = high[i] + signal[n-2]; } template <typename TYPE> void _5_3<TYPE>::odd_analyze(TYPE *signal, TYPE *low, TYPE *high, int n) { int i; for(i=0;i<n/2;i++) { int i2 = i<<1; //high[i] = signal[i2+1] - ((signal[i2]+signal[i2+2])>>1); high[i] = signal[i2+1] - (signal[i2]+signal[i2+2])/2; } //low[0] = signal[0] + ((high[0]+1)>>1); low[0] = signal[0] + high[0]/2; for(i=1;i<n/2;i++) { int i2 = i<<1; //low[i] = signal[i2] + ((high[i]+high[i-1]+2)>>2); low[i] = signal[i2] + (high[i]+high[i-1])/4; } //low[i] = signal[n-1] + ((high[i-1]+1)>>1); low[i] = signal[n-1] + high[i-1]/2; } template <typename TYPE> void _5_3<TYPE>::odd_synthesize(TYPE *signal, TYPE *low, TYPE *high, int n) { int i; //signal[0] = low[0] - ((high[0]+1)>>1); signal[0] = low[0] - high[0]/2; for(i=1;i<n/2;i++) { int i2 = i<<1; //signal[i2] = low[i] - ((high[i]+high[i-1]+2)>>2); signal[i2] = low[i] - (high[i]+high[i-1])/4; } //signal[n-1] = low[i] - ((high[i-1]+1)>>1); signal[n-1] = low[i] - high[i-1]/2; for(i=0;i<n/2;i++) { int i2 = i<<1; //signal[i2+1] = high[i] + ((signal[i2]+signal[i2+2])>>1); signal[i2+1] = high[i] + (signal[i2]+signal[i2+2])/2; } } |