Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

Haar.c File Reference

Go to the source code of this file.


Functions

void Haar_ip_FFWT_1d (int n, float *s)
void Haar_ip_IFWT_1d (int n, float *s)
void Haar_forward_pass_1d (int n, float *s)
void Haar_forward_FWT_1d (int n, float *s)
void Haar_inverse_pass_1d (int n, float *s)
void Haar_inverse_FWT_1d (int n, float *s)
void Haar_forward_pass_2d (int n, float **s)
void Haar_forward_FWT_2d (int n, float **s)
void Haar_inverse_pass_2d (int n, float **s)
void Haar_inverse_FWT_2d (int n, float **s)

Function Documentation

void Haar_forward_FWT_1d int    n,
float *    s
 

Definition at line 139 of file Haar.c.

References Haar_forward_pass_1d(), and powerof2().

Referenced by wavelet_analysis().

00140 {
00141   int m;
00142   int npts;
00143 
00144   npts = powerof2 (n);
00145 
00146   for (m = n-1;  m >= 0;  m--)
00147     {
00148       Haar_forward_pass_1d (m+1, s);
00149       /*
00150       ts_print (npts, s);
00151       */
00152     }
00153 }

void Haar_forward_FWT_2d int    n,
float **    s
 

Definition at line 246 of file Haar.c.

References Haar_forward_pass_2d(), and powerof2().

00247 {
00248   int m;
00249   int npts;
00250 
00251   npts = powerof2 (n);
00252 
00253   for (m = n-1;  m >= 0;  m--)
00254     {
00255       Haar_forward_pass_2d (m+1, s);
00256     }
00257 }

void Haar_forward_pass_1d int    n,
float *    s
 

Definition at line 106 of file Haar.c.

References a, c, free, i, malloc, and powerof2().

Referenced by Haar_forward_FWT_1d(), and Haar_forward_pass_2d().

00107 {
00108   int i;
00109   int npts;
00110   float * a = NULL;
00111   float * c = NULL;
00112 
00113   npts = powerof2 (n);
00114   a = (float *) malloc (sizeof(float) * npts/2);
00115   c = (float *) malloc (sizeof(float) * npts/2);
00116   
00117   for (i = 0;  i < npts/2;  i++)
00118     {
00119       a[i] = (s[2*i] + s[2*i+1]) / 2.0;
00120       c[i] = (s[2*i] - s[2*i+1]) / 2.0;
00121     }
00122 
00123   for (i = 0;  i < npts/2;  i++)
00124     {
00125       s[i] = a[i];
00126       s[i + npts/2] = c[i];
00127     }
00128 
00129   free (a);   a = NULL;
00130   free (c);   c = NULL;
00131 }

void Haar_forward_pass_2d int    n,
float **    s
 

Definition at line 212 of file Haar.c.

References c, free, Haar_forward_pass_1d(), i, malloc, and powerof2().

Referenced by Haar_forward_FWT_2d().

00213 {
00214   int i, j;
00215   int npts;
00216   float * c = NULL;
00217 
00218 
00219   npts = powerof2 (n);
00220 
00221   for (i = 0;  i < npts;  i++)
00222     {
00223       Haar_forward_pass_1d (n, s[i]);
00224     }
00225 
00226   c = (float *) malloc (sizeof(float) * npts);
00227 
00228   for (j = 0;  j < npts;  j++)
00229     {
00230       for (i = 0;  i < npts;  i++)
00231         c[i] = s[i][j];
00232       Haar_forward_pass_1d (n, c);
00233       for (i = 0;  i < npts;  i++)
00234         s[i][j] = c[i];
00235     }
00236 
00237   free (c);   c = NULL;
00238 }

void Haar_inverse_FWT_1d int    n,
float *    s
 

Definition at line 190 of file Haar.c.

References Haar_inverse_pass_1d(), and powerof2().

Referenced by wavelet_analysis().

00191 {
00192   int m;
00193   int npts;
00194 
00195   npts = powerof2 (n);
00196 
00197   for (m = 1;  m <=n;  m++)
00198     {
00199       Haar_inverse_pass_1d (m, s);
00200       /*
00201       ts_print (npts, s);
00202       */
00203     }
00204 }

void Haar_inverse_FWT_2d int    n,
float **    s
 

Definition at line 299 of file Haar.c.

References Haar_inverse_pass_2d(), and powerof2().

00300 {
00301   int m;
00302   int npts;
00303 
00304   npts = powerof2 (n);
00305 
00306   for (m = 1;  m <= n;  m++)
00307     {
00308       Haar_inverse_pass_2d (m, s);
00309     }
00310 }

void Haar_inverse_pass_1d int    n,
float *    s
 

Definition at line 161 of file Haar.c.

References free, i, malloc, powerof2(), and r.

Referenced by Haar_inverse_FWT_1d(), and Haar_inverse_pass_2d().

00162 {
00163   int i;
00164   int npts;
00165   float * r = NULL;
00166 
00167   npts = powerof2 (n);
00168   r = (float *) malloc (sizeof(float) * npts);
00169   
00170   for (i = 0;  i < npts/2;  i++)
00171     {
00172       r[2*i]   = s[i] + s[i + npts/2];
00173       r[2*i+1] = s[i] - s[i + npts/2]; 
00174     }
00175 
00176   for (i = 0;  i < npts;  i++)
00177     {
00178       s[i] = r[i];
00179     }
00180 
00181   free (r);   r = NULL;
00182 }

void Haar_inverse_pass_2d int    n,
float **    s
 

Definition at line 265 of file Haar.c.

References c, free, Haar_inverse_pass_1d(), i, malloc, and powerof2().

Referenced by Haar_inverse_FWT_2d().

00266 {
00267   int i, j;
00268   int npts;
00269   float * c = NULL;
00270 
00271 
00272   npts = powerof2 (n);
00273 
00274   for (i = 0;  i < npts;  i++)
00275     {
00276       Haar_inverse_pass_1d (n, s[i]);
00277     }
00278 
00279   c = (float *) malloc (sizeof(float) * npts);
00280 
00281   for (j = 0;  j < npts;  j++)
00282     {
00283       for (i = 0;  i < npts;  i++)
00284         c[i] = s[i][j];
00285       Haar_inverse_pass_1d (n, c);
00286       for (i = 0;  i < npts;  i++)
00287         s[i][j] = c[i];
00288     }
00289 
00290   free (c);   c = NULL;
00291 }

void Haar_ip_FFWT_1d int    n,
float *    s
 

Definition at line 22 of file Haar.c.

References a, c, i, l, and powerof2().

00023 {
00024   float a;
00025   float c;
00026   int i;
00027   int j;
00028   int k;
00029   int l;
00030   int m;
00031 
00032 
00033   i = 1;
00034   j = 2;
00035   m = powerof2 (n);
00036 
00037   for (l = n-1;  l >= 0;  l--)
00038     {
00039       printf ("l = %d \n", l);
00040       m /= 2;
00041 
00042       for (k = 0;  k < m;  k++)
00043         {
00044           a = (s[j*k] + s[j*k+i]) / 2.0;
00045           c = (s[j*k] - s[j*k+i]) / 2.0;
00046           s[j*k] = a;
00047           s[j*k+i] = c;
00048         }
00049       
00050       i *= 2;
00051       j *= 2;
00052       /*
00053       ts_print (powerof2(n), s);
00054       */
00055     }
00056 }

void Haar_ip_IFWT_1d int    n,
float *    s
 

Definition at line 64 of file Haar.c.

References i, l, and powerof2().

00065 {
00066   float a0;
00067   float a1;
00068   int i;
00069   int j;
00070   int k;
00071   int l;
00072   int m;
00073 
00074 
00075   i = powerof2 (n-1);
00076   j = 2*i;
00077   m = 1;
00078 
00079   for (l = 1;  l <= n;  l++)
00080     {
00081       printf ("l = %d \n", l);
00082 
00083       for (k = 0;  k < m;  k++)
00084         {
00085           a0 = s[j*k] + s[j*k+i];
00086           a1 = s[j*k] - s[j*k+i];
00087           s[j*k] = a0;
00088           s[j*k+i] = a1;
00089         }
00090       
00091       i /= 2;
00092       j /= 2;
00093       m *= 2;
00094       /*
00095       ts_print (powerof2(n), s);
00096       */
00097     }
00098 }
 

Powered by Plone

This site conforms to the following standards: