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  

Daubechies.c File Reference

Go to the source code of this file.


Functions

void Daubechies_forward_pass_1d (int n, float *s)
void Daubechies_forward_FWT_1d (int n, float *s)
void Daubechies_inverse_pass_1d (int n, float *s)
void Daubechies_inverse_FWT_1d (int n, float *s)
void Daubechies_forward_pass_2d (int n, float **s)
void Daubechies_forward_FWT_2d (int n, float **s)
void Daubechies_inverse_pass_2d (int n, float **s)
void Daubechies_inverse_FWT_2d (int n, float **s)

Function Documentation

void Daubechies_forward_FWT_1d int    n,
float *    s
 

Definition at line 59 of file Daubechies.c.

References Daubechies_forward_pass_1d(), and powerof2().

Referenced by wavelet_analysis().

00060 {
00061   int m;
00062   int npts;
00063 
00064   npts = powerof2 (n);
00065 
00066   for (m = n-1;  m >= 0;  m--)
00067     {
00068       Daubechies_forward_pass_1d (m+1, s);
00069       /*
00070       ts_print (npts, s);
00071       */
00072     }
00073 }

void Daubechies_forward_FWT_2d int    n,
float **    s
 

Definition at line 179 of file Daubechies.c.

References Daubechies_forward_pass_2d(), and powerof2().

00180 {
00181   int m;
00182   int npts;
00183 
00184   npts = powerof2 (n);
00185 
00186   for (m = n-1;  m >= 0;  m--)
00187     {
00188       Daubechies_forward_pass_2d (m+1, s);
00189     }
00190 }

void Daubechies_forward_pass_1d int    n,
float *    s
 

Definition at line 23 of file Daubechies.c.

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

Referenced by Daubechies_forward_FWT_1d(), and Daubechies_forward_pass_2d().

00024 {
00025   int i;
00026   int npts;
00027   float * a = NULL;
00028   float * c = NULL;
00029   const float h[4] = { 0.683013, 1.18301, 0.316987, -0.183013 };
00030 
00031   npts = powerof2 (n);
00032   a = (float *) malloc (sizeof(float) * npts/2);
00033   c = (float *) malloc (sizeof(float) * npts/2);
00034   
00035   for (i = 0;  i < npts/2;  i++)
00036     {
00037       a[i] = (h[0]*s[(2*i)%npts] + h[1]*s[(2*i+1)%npts] + h[2]*s[(2*i+2)%npts]
00038               + h[3]*s[(2*i+3)%npts]) / 2.0;
00039       c[i] = (h[3]*s[(2*i)%npts] - h[2]*s[(2*i+1)%npts] + h[1]*s[(2*i+2)%npts] 
00040               - h[0]*s[(2*i+3)%npts]) / 2.0;
00041     }
00042 
00043   for (i = 0;  i < npts/2;  i++)
00044     {
00045       s[i] = a[i];
00046       s[i + npts/2] = c[i];
00047     }
00048 
00049   free (a);   a = NULL;
00050   free (c);   c = NULL;
00051 }

void Daubechies_forward_pass_2d int    n,
float **    s
 

Definition at line 145 of file Daubechies.c.

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

Referenced by Daubechies_forward_FWT_2d().

00146 {
00147   int i, j;
00148   int npts;
00149   float * c = NULL;
00150 
00151 
00152   npts = powerof2 (n);
00153 
00154   for (i = 0;  i < npts;  i++)
00155     {
00156       Daubechies_forward_pass_1d (n, s[i]);
00157     }
00158 
00159   c = (float *) malloc (sizeof(float) * npts);
00160 
00161   for (j = 0;  j < npts;  j++)
00162     {
00163       for (i = 0;  i < npts;  i++)
00164         c[i] = s[i][j];
00165       Daubechies_forward_pass_1d (n, c);
00166       for (i = 0;  i < npts;  i++)
00167         s[i][j] = c[i];
00168     }
00169 
00170   free (c);   c = NULL;
00171 }

void Daubechies_inverse_FWT_1d int    n,
float *    s
 

Definition at line 123 of file Daubechies.c.

References Daubechies_inverse_pass_1d(), and powerof2().

Referenced by wavelet_analysis().

00124 {
00125   int m;
00126   int npts;
00127 
00128   npts = powerof2 (n);
00129 
00130   for (m = 1;  m <=n;  m++)
00131     {
00132       Daubechies_inverse_pass_1d (m, s);
00133       /*
00134       ts_print (npts, s);
00135       */
00136     }
00137 }

void Daubechies_inverse_FWT_2d int    n,
float **    s
 

Definition at line 232 of file Daubechies.c.

References Daubechies_inverse_pass_2d(), and powerof2().

00233 {
00234   int m;
00235   int npts;
00236 
00237   npts = powerof2 (n);
00238 
00239   for (m = 1;  m <= n;  m++)
00240     {
00241       Daubechies_inverse_pass_2d (m, s);
00242     }
00243 }

void Daubechies_inverse_pass_1d int    n,
float *    s
 

Definition at line 81 of file Daubechies.c.

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

Referenced by Daubechies_inverse_FWT_1d(), and Daubechies_inverse_pass_2d().

00082 {
00083   int i;
00084   int npts, nptsd2;
00085   float * a = NULL;
00086   float * c = NULL;
00087   float * r = NULL;
00088   const float h[4] = { 0.683013, 1.18301, 0.316987, -0.183013 };
00089 
00090 
00091   npts = powerof2 (n);
00092   nptsd2 = npts/2;
00093   a = s;
00094   c = s+nptsd2;
00095   r = (float *) malloc (sizeof(float) * npts);
00096   
00097 
00098   for (i = 0;  i < nptsd2;  i++)
00099     {
00100       r[2*i]   = h[2]*a[(i-1+nptsd2)%nptsd2] + h[1]*c[(i-1+nptsd2)%nptsd2] 
00101                + h[0]*a[i] + h[3]*c[i];
00102                
00103       r[2*i+1] = h[3]*a[(i-1+nptsd2)%nptsd2] - h[0]*c[(i-1+nptsd2)%nptsd2] 
00104                + h[1]*a[i] - h[2]*c[i];
00105     }
00106 
00107 
00108   for (i = 0;  i < npts;  i++)
00109     {
00110       s[i] = r[i];
00111     }
00112 
00113   free (r);   r = NULL;
00114 
00115 }

void Daubechies_inverse_pass_2d int    n,
float **    s
 

Definition at line 198 of file Daubechies.c.

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

Referenced by Daubechies_inverse_FWT_2d().

00199 {
00200   int i, j;
00201   int npts;
00202   float * c = NULL;
00203 
00204 
00205   npts = powerof2 (n);
00206 
00207   for (i = 0;  i < npts;  i++)
00208     {
00209       Daubechies_inverse_pass_1d (n, s[i]);
00210     }
00211 
00212   c = (float *) malloc (sizeof(float) * npts);
00213 
00214   for (j = 0;  j < npts;  j++)
00215     {
00216       for (i = 0;  i < npts;  i++)
00217         c[i] = s[i][j];
00218       Daubechies_inverse_pass_1d (n, c);
00219       for (i = 0;  i < npts;  i++)
00220         s[i][j] = c[i];
00221     }
00222 
00223   free (c);   c = NULL;
00224 }
 

Powered by Plone

This site conforms to the following standards: