~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/vision/improc/im_erf.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <math.h>
  2 #include <limits.h>
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 Imrect *imf_erf(Imrect * im1, double *thresh, double *ml)
 11 {
 12     Imrect *im2;
 13     Imregion *roi;
 14     float  *row1, *row2;
 15     int     lx, ux, ly, uy;
 16     int     i, j;
 17 
 18     if (im1 == NULL)
 19         return (NULL);
 20 
 21     roi = im1->region;
 22     if (roi == NULL)
 23         return (NULL);
 24     lx = roi->lx;
 25     ux = roi->ux;
 26     ly = roi->ly;
 27     uy = roi->uy;
 28 
 29     im2 = im_alloc(im1->height, im1->width, roi, float_v);
 30     row1 = fvector_alloc(lx, ux);
 31     row2 = fvector_alloc(lx, ux);
 32 
 33     for (i = ly; i < uy; ++i)
 34     {
 35         im_get_rowf(row1, im1, i, lx, ux);
 36         for (j = lx; j < ux; ++j)
 37         {
 38             row2[j] = (float)0.50*(erfc( 0.7071*(*thresh-row1[j]) ));
 39             if (row2[j] <= sqrt(MINFLOAT))
 40                   row2[j] = sqrt(MINFLOAT);
 41         }
 42         im_put_rowf(row2, im2, i, lx, ux);
 43     }
 44 
 45     fvector_free((void *) row1, lx);
 46     fvector_free((void *) row2, lx);
 47     *ml = 0.0;
 48     return (im2);
 49 }
 50 
 51 Imrect *imz_erf(Imrect * im1, double *thresh, double *ml)
 52 {
 53     Imrect *im2;
 54     Imregion *roi;
 55     Complex *row1;
 56     float *row2;
 57     char temp[260];
 58     double ml_total = 0.0;
 59     int     vox_tot=0.0;
 60     int     lx, ux, ly, uy;
 61     int     i, j, k;
 62 
 63     if (im1 == NULL)
 64         return (NULL);
 65 
 66     roi = im1->region;
 67     if (roi == NULL)
 68         return (NULL);
 69     lx = roi->lx;
 70     ux = roi->ux;
 71     ly = roi->ly;
 72     uy = roi->uy;
 73 
 74     im2 = im_alloc(im1->height, im1->width, roi, float_v);
 75     row1 = zvector_alloc(lx, ux);
 76     row2 = fvector_alloc(lx, ux);
 77 
 78     ml_total = 0.0;
 79     for (i = ly; i < uy; ++i)
 80     {
 81         im_get_rowz(row1, im1, i, lx, ux);
 82         for (j = lx; j < ux; ++j)
 83         {
 84             if (cmplx_re(row1[j])==1)
 85             {
 86                 vox_tot ++; 
 87                 ml_total += cmplx_im(row1[j]);
 88             }
 89         }
 90     }
 91    sprintf(temp,"total z %f ndf %d \n",ml_total/sqrt(vox_tot),vox_tot);
 92    format(temp);
 93     for (i = ly; i < uy; ++i)
 94     {
 95        im_get_rowz(row1, im1, i, lx, ux);
 96        for (j = lx; j < ux; ++j)
 97        {   
 98           if (cmplx_re(row1[j])==1)
 99           {  
100              row2[j] = (float)0.5*(erfc( 0.7071*(*thresh)-0.5*cmplx_im(row1[j]) ));
101              if (row2[j] <= sqrt(MINFLOAT))
102                  row2[j] = sqrt(MINFLOAT);
103           }
104           else if (cmplx_re(row1[j])==0)
105           {  
106              row2[j] = 1.0 - 0.5*(erfc( 0.7071*(*thresh)-0.5*cmplx_im(row1[j]) ));
107              if (row2[j] <= sqrt(MINFLOAT))
108                  row2[j] = sqrt(MINFLOAT);
109           }
110        }
111        im_put_rowf(row2, im2, i, lx, ux);
112     }
113 
114 
115     zvector_free((void *) row1, lx);
116     fvector_free((void *) row2, lx);
117     *ml = ml_total;
118     return (im2);
119 }
120 
121 Imrect *im_erf(Imrect * im, double *thresh, double *ml)
122 {
123     switch (im->vtype)
124     {
125         case complex_v:
126         return (imz_erf(im,thresh,ml));
127     default:
128         return (imf_erf(im,thresh,ml));
129     }
130 }
131 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.