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

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

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

  1 #include <math.h>
  2 #include <tina/sys.h>
  3 #include <tina/sysfuncs.h>
  4 #include <tina/math.h>
  5 #include <tina/mathfuncs.h>
  6 #include <tina/vision.h>
  7 #include <tina/visionfuncs.h>
  8 
  9 Imrect *imf_sqrt(Imrect * im1)
 10 {
 11     Imrect *im2;
 12     Imregion *roi;
 13     float  *row1, *row2;
 14     int     lx, ux, ly, uy;
 15     int     i, j;
 16 
 17     if (im1 == NULL)
 18         return (NULL);
 19 
 20     roi = im1->region;
 21     if (roi == NULL)
 22         return (NULL);
 23     lx = roi->lx;
 24     ux = roi->ux;
 25     ly = roi->ly;
 26     uy = roi->uy;
 27 
 28     im2 = im_alloc(im1->height, im1->width, roi, float_v);
 29     row1 = fvector_alloc(lx, ux);
 30     row2 = fvector_alloc(lx, ux);
 31 
 32     for (i = ly; i < uy; ++i)
 33     {
 34         im_get_rowf(row1, im1, i, lx, ux);
 35         for (j = lx; j < ux; ++j)
 36             if (row1[j] >= 0.0)
 37                 row2[j] = (float)sqrt(row1[j]);
 38             else
 39                 row2[j] = (float)-sqrt(-row1[j]);
 40         im_put_rowf(row2, im2, i, lx, ux);
 41     }
 42 
 43     fvector_free((void *) row1, lx);
 44     fvector_free((void *) row2, lx);
 45     return (im2);
 46 }
 47 
 48 Imrect *imz_sqrt(Imrect * im1)
 49 {
 50     Imrect *im2;
 51     Imregion *roi;
 52     Complex *row1;
 53     Complex *row2;
 54     int     lx, ux, ly, uy;
 55     int     i, j;
 56 
 57     if (im1 == NULL)
 58         return (NULL);
 59 
 60     roi = im1->region;
 61     if (roi == NULL)
 62         return (NULL);
 63     lx = roi->lx;
 64     ux = roi->ux;
 65     ly = roi->ly;
 66     uy = roi->uy;
 67 
 68     im2 = im_alloc(im1->height, im1->width, roi, complex_v);
 69     row1 = zvector_alloc(lx, ux);
 70     row2 = zvector_alloc(lx, ux);
 71 
 72     for (i = ly; i < uy; ++i)
 73     {
 74         im_get_rowz(row1, im1, i, lx, ux);
 75         for (j = lx; j < ux; ++j)
 76             row2[j] = cmplx_sqrt(row1[j]);
 77         im_put_rowz(row2, im2, i, lx, ux);
 78     }
 79 
 80     zvector_free((void *) row1, lx);
 81     zvector_free((void *) row2, lx);
 82     return (im2);
 83 }
 84 
 85 Imrect *im_sqrt(Imrect * im)
 86 {
 87     switch (im->vtype)
 88     {
 89         case complex_v:
 90         return (imz_sqrt(im));
 91     default:
 92         return (imf_sqrt(im));
 93     }
 94 }
 95 

~ [ 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.