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

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

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

  1 #include <math.h>
  2 #include <values.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_log(Imrect * im1)
 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              if (row1[j]>0.0)
 38                 row2[j] = (float)log(row1[j]);
 39              else if(row1[j] == 0.0)
 40                 row2[j] = - MAXFLOAT;
 41              else
 42                 row2[j] = (float)log(-row1[j]);
 43         im_put_rowf(row2, im2, i, lx, ux);
 44     }
 45 
 46     fvector_free((void *) row1, lx);
 47     fvector_free((void *) row2, lx);
 48     return (im2);
 49 }
 50 
 51 Imrect *imz_log(Imrect * im1)
 52 {
 53     Imrect *im2;
 54     Imregion *roi;
 55     Complex *row1;
 56     Complex *row2;
 57     int     lx, ux, ly, uy;
 58     int     i, j;
 59 
 60     if (im1 == NULL)
 61         return (NULL);
 62 
 63     roi = im1->region;
 64     if (roi == NULL)
 65         return (NULL);
 66     lx = roi->lx;
 67     ux = roi->ux;
 68     ly = roi->ly;
 69     uy = roi->uy;
 70 
 71     im2 = im_alloc(im1->height, im1->width, roi, complex_v);
 72     row1 = zvector_alloc(lx, ux);
 73     row2 = zvector_alloc(lx, ux);
 74 
 75     for (i = ly; i < uy; ++i)
 76     {
 77         im_get_rowz(row1, im1, i, lx, ux);
 78         for (j = lx; j < ux; ++j)
 79             row2[j] = cmplx_log(row1[j]);
 80         im_put_rowz(row2, im2, i, lx, ux);
 81     }
 82 
 83     zvector_free((void *) row1, lx);
 84     zvector_free((void *) row2, lx);
 85     return (im2);
 86 }
 87 
 88 Imrect *im_log(Imrect * im)
 89 {
 90     switch (im->vtype)
 91     {
 92         case complex_v:
 93         return (imz_log(im));
 94     default:
 95         return (imf_log(im));
 96     }
 97 }
 98 
 99 Imrect *imf_exp(Imrect * im1)
100 {
101     Imrect *im2;
102     Imregion *roi;
103     float  *row1, *row2;
104     int     lx, ux, ly, uy;
105     int     i, j;
106 
107     if (im1 == NULL)
108         return (NULL);
109 
110     roi = im1->region;
111     if (roi == NULL)
112         return (NULL);
113     lx = roi->lx;
114     ux = roi->ux;
115     ly = roi->ly;
116     uy = roi->uy;
117 
118     im2 = im_alloc(im1->height, im1->width, roi, float_v);
119     row1 = fvector_alloc(lx, ux);
120     row2 = fvector_alloc(lx, ux);
121 
122     for (i = ly; i < uy; ++i)
123     {
124         im_get_rowf(row1, im1, i, lx, ux);
125         for (j = lx; j < ux; ++j)
126             row2[j] = (float)exp(row1[j]);
127         im_put_rowf(row2, im2, i, lx, ux);
128     }
129 
130     fvector_free((void *) row1, lx);
131     fvector_free((void *) row2, lx);
132     return (im2);
133 }
134 
135 Imrect *imz_exp(Imrect * im1)
136 {
137     Imrect *im2;
138     Imregion *roi;
139     Complex *row1;
140     Complex *row2;
141     int     lx, ux, ly, uy;
142     int     i, j;
143 
144     if (im1 == NULL)
145         return (NULL);
146 
147     roi = im1->region;
148     if (roi == NULL)
149         return (NULL);
150     lx = roi->lx;
151     ux = roi->ux;
152     ly = roi->ly;
153     uy = roi->uy;
154 
155     im2 = im_alloc(im1->height, im1->width, roi, complex_v);
156     row1 = zvector_alloc(lx, ux);
157     row2 = zvector_alloc(lx, ux);
158 
159     for (i = ly; i < uy; ++i)
160     {
161         im_get_rowz(row1, im1, i, lx, ux);
162         for (j = lx; j < ux; ++j)
163             row2[j] = cmplx_exp(row1[j]);
164         im_put_rowz(row2, im2, i, lx, ux);
165     }
166 
167     zvector_free((void *) row1, lx);
168     zvector_free((void *) row2, lx);
169     return (im2);
170 }
171 
172 Imrect *im_exp(Imrect * im)
173 {
174     switch (im->vtype)
175     {
176         case complex_v:
177         return (imz_exp(im));
178     default:
179         return (imf_exp(im));
180     }
181 }
182 

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