From: clynejp <cl...@us...> - 2006-08-31 22:19:18
|
Update of /cvsroot/vapor/vapor/include/vapor In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv24419 Modified Files: Lifting1D.h Log Message: Added 'stride' parameter to permit multi-dimensional transforms without transposing the array Index: Lifting1D.h =================================================================== RCS file: /cvsroot/vapor/vapor/include/vapor/Lifting1D.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Lifting1D.h 13 Jul 2006 23:10:41 -0000 1.6 --- Lifting1D.h 31 Aug 2006 22:19:16 -0000 1.7 *************** *** 51,55 **** //! \sa InverseTransform(), Lifting1D() // ! void ForwardTransform(Data_T *data); //! Apply inverse lifting transform --- 51,55 ---- //! \sa InverseTransform(), Lifting1D() // ! void ForwardTransform(Data_T *data, int stride = 1); //! Apply inverse lifting transform *************** *** 60,64 **** //! \sa ForwardTransform(), Lifting1D() // ! void InverseTransform(Data_T *data); private: --- 60,64 ---- //! \sa ForwardTransform(), Lifting1D() // ! void InverseTransform(Data_T *data, int stride = 1); private: *************** *** 114,123 **** ); ! void FLWT1D_Predict(Data_T*, const long, const long, double *); ! void FLWT1D_Update(Data_T *, const long, const long, const double*); ! void forward_transform1d_haar(Data_T *data, int width); ! void inverse_transform1d_haar(Data_T *data, int width); --- 114,123 ---- ); ! void FLWT1D_Predict(Data_T*, const long, const long, double *, int stride); ! void FLWT1D_Update(Data_T *, const long, const long, const double*, int stride); ! void forward_transform1d_haar(Data_T *data, int width, int stride); ! void inverse_transform1d_haar(Data_T *data, int width, int stride); *************** *** 312,323 **** // template <class Data_T> void Lifting1D<Data_T>::ForwardTransform( ! Data_T *data ) { if (n_c == 1 && ntilde_c == 1) { ! forward_transform1d_haar(data, width_c); } else { ! FLWT1D_Predict (data, width_c, n_c, fwd_filter_c); ! FLWT1D_Update (data, width_c, ntilde_c, fwd_lifting_c); } --- 312,323 ---- // template <class Data_T> void Lifting1D<Data_T>::ForwardTransform( ! Data_T *data, int stride ) { if (n_c == 1 && ntilde_c == 1) { ! forward_transform1d_haar(data, width_c, stride); } else { ! FLWT1D_Predict (data, width_c, n_c, fwd_filter_c, stride); ! FLWT1D_Update (data, width_c, ntilde_c, fwd_lifting_c, stride); } *************** *** 325,329 **** // normalize the detail coefficents for(unsigned int i=1; i<width_c; i+=2) { ! data[i] /= _nfactor; } } --- 325,329 ---- // normalize the detail coefficents for(unsigned int i=1; i<width_c; i+=2) { ! data[i*stride] /= _nfactor; } } *************** *** 339,357 **** // template <class Data_T> void Lifting1D<Data_T>::InverseTransform( ! Data_T *data ) { if (_nfactor != 1.0) { // un-normalize the detail coefficents for(unsigned int i=1; i<width_c; i+=2) { ! data[i] *= _nfactor; } } if (n_c == 1 && ntilde_c == 1) { ! inverse_transform1d_haar(data, width_c); } else { ! FLWT1D_Update (data, width_c, ntilde_c, inv_lifting_c); ! FLWT1D_Predict (data, width_c, n_c, inv_filter_c); } } --- 339,357 ---- // template <class Data_T> void Lifting1D<Data_T>::InverseTransform( ! Data_T *data, int stride ) { if (_nfactor != 1.0) { // un-normalize the detail coefficents for(unsigned int i=1; i<width_c; i+=2) { ! data[i*stride] *= _nfactor; } } if (n_c == 1 && ntilde_c == 1) { ! inverse_transform1d_haar(data, width_c, stride); } else { ! FLWT1D_Update (data, width_c, ntilde_c, inv_lifting_c, stride); ! FLWT1D_Predict (data, width_c, n_c, inv_filter_c, stride); } } *************** *** 995,999 **** const long width, const long N, ! double *filter ) { register Data_T *lambdaPtr, //pointer to Lambda coeffs --- 995,1000 ---- const long width, const long N, ! double *filter, ! int stride ) { register Data_T *lambdaPtr, //pointer to Lambda coeffs *************** *** 1013,1017 **** /************************************************/ len = CEIL(width, 1); /* number of coefficients at current level */ ! stepIncr = 1 << 1; /* step size betweeen coefficients */ /************************************************/ --- 1014,1018 ---- /************************************************/ len = CEIL(width, 1); /* number of coefficients at current level */ ! stepIncr = stride << 1; /* step size betweeen coefficients */ /************************************************/ *************** *** 1086,1090 **** const long width, const long nTilde, ! const double * lc ) { const register double * lcPtr; /* pointer to lifting coefficient values */ --- 1087,1092 ---- const long width, const long nTilde, ! const double *lc, ! int stride ) { const register double * lcPtr; /* pointer to lifting coefficient values */ *************** *** 1106,1110 **** /************************************************/ len = CEIL(width, 1); /* number of coefficients at current level */ ! stepIncr = 1 << 1; /* step size between coefficients */ noGammas = len >> 1 ; /* number of Gamma coefficients */ --- 1108,1112 ---- /************************************************/ len = CEIL(width, 1); /* number of coefficients at current level */ ! stepIncr = stride << 1; /* step size between coefficients */ noGammas = len >> 1 ; /* number of Gamma coefficients */ *************** *** 1168,1172 **** template <class Data_T> void Lifting1D<Data_T>::forward_transform1d_haar( Data_T *data, ! int width ) { int i; --- 1170,1175 ---- template <class Data_T> void Lifting1D<Data_T>::forward_transform1d_haar( Data_T *data, ! int width, ! int stride ) { int i; *************** *** 1176,1179 **** --- 1179,1184 ---- double lsum = 0.0; // sum of lambda values double lave = 0.0; // average of lambda values + int stepIncr = stride << 1; // step size betweeen coefficients + nG = (width >> 1); *************** *** 1187,1191 **** for(i=0;i<width;i++) { ! t += data[i]; } lave = t / (double) width; --- 1192,1196 ---- for(i=0;i<width;i++) { ! t += data[i*stride]; } lave = t / (double) width; *************** *** 1193,1201 **** for (i=0; i<nG; i++) { ! data[1] = data[1] - data[0]; // gamma ! data[0] = (Data_T)(data[0] + (data[1] /2.0)); // lambda lsum += data[0]; ! data += 2; } --- 1198,1206 ---- for (i=0; i<nG; i++) { ! data[stride] = data[stride] - data[0]; // gamma ! data[0] = (Data_T)(data[0] + (data[stride] /2.0)); // lambda lsum += data[0]; ! data += stepIncr; } *************** *** 1213,1217 **** template <class Data_T> void Lifting1D<Data_T>::inverse_transform1d_haar( Data_T *data, ! int width ) { int i,j; --- 1218,1223 ---- template <class Data_T> void Lifting1D<Data_T>::inverse_transform1d_haar( Data_T *data, ! int width, ! int stride ) { int i,j; *************** *** 1221,1224 **** --- 1227,1232 ---- double lave = 0.0; // average of lambda values + int stepIncr = stride << 1; // step size betweeen coefficients + nG = (width >> 1); nL = width - nG; *************** *** 1230,1234 **** double t = 0.0; ! for(i=0,j=0;i<nL;i++,j+=2) { t += data[j]; } --- 1238,1242 ---- double t = 0.0; ! for(i=0,j=0;i<nL;i++,j+=stepIncr) { t += data[j]; } *************** *** 1237,1245 **** for (i=0; i<nG; i++) { ! data[0] = (Data_T)(data[0] - (data[1] * 0.5)); ! data[1] = data[1] + data[0]; ! lsum += data[0] + data[1]; ! data += 2; } --- 1245,1253 ---- for (i=0; i<nG; i++) { ! data[0] = (Data_T)(data[0] - (data[stride] * 0.5)); ! data[stride] = data[stride] + data[0]; ! lsum += data[0] + data[stride]; ! data += stepIncr; } |