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

Linux Cross Reference
Tina4/src/tools/coreg/csf_count.c

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

  1 #include <stdio.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 #include <tina/tv.h>
  9 #include <tina/tvfuncs.h>
 10 #include <tina/draw.h>
 11 #include <tina/drawfuncs.h>
 12 #include <tina/seqoral.h>
 13 extern void ***coreg_limits(int *lz, int *uz, int *ly,
 14                          int *uy, int *lx, int *ux);
 15 extern void coreg_coords(Vec3 *ex, Vec3 *ey, Vec3 *ez);
 16 extern void coreg_centre(double *x,double *y,double *z, Vec3 *c);
 17 extern void coreg_scales(double *x, double *y, double *z,
 18                          double *nx, double *ny, double *nz);
 19 extern float (nearest_pixel)(void ***rasptrs, Vec3 pos);
 20 extern Tv *xcoreg_tv_get();
 21 extern Tv *ycoreg_tv_get();
 22 extern Tv *zcoreg_tv_get();
 23 extern void coreg_slice_init(Vec3 *scales);
 24 static void ***imptrs=NULL;
 25 static Vec3 coreg_ex, coreg_ey, coreg_ez, coreg_c;
 26 
 27 
 28 csf_count_proc()
 29 {
 30     Vec3 ex,ey,ez,posi,post;
 31     int i,j,k;
 32     Imrect *im;
 33     Imregion roi;
 34     double count[8];
 35     int imptrlx, imptrux,imptrly, imptruy, imptrlz, imptruz;
 36     int nimptrlx, nimptrux, nimptrly, nimptruy, nimptrlz, nimptruz;
 37     float timptrlx, timptrux, timptrly, timptruy, timptrlz, timptruz;
 38     double xcentre = 128.0;
 39     double ycentre = 128.0;
 40     double zcentre = 40.0;
 41     double xscale = 1.0;
 42     double yscale = 1.0;
 43     double zscale = 2.0;
 44     double nxscale = 1.0;
 45     double nyscale = 1.0;
 46     double nzscale = 2.0;
 47 
 48 
 49 
 50     imptrs = coreg_limits(&imptrlz,&imptruz,&imptrly,&imptruy,&imptrlx,&imptrux);
 51     coreg_coords(&coreg_ex,&coreg_ey,&coreg_ez);
 52     coreg_centre(&xcentre,&ycentre,&zcentre,&coreg_c);
 53     coreg_scales(&xscale,&yscale,&zscale,&nxscale,&nyscale,&nzscale);
 54     ex.el[0] = coreg_ex.el[0];
 55     ex.el[1] = coreg_ey.el[0];
 56     ex.el[2] = coreg_ez.el[0];
 57     ey.el[0] = coreg_ex.el[1];
 58     ey.el[1] = coreg_ey.el[1];
 59     ey.el[2] = coreg_ez.el[1];
 60     ez.el[0] = coreg_ex.el[2];
 61     ez.el[1] = coreg_ey.el[2];
 62     ez.el[2] = coreg_ez.el[2];
 63     count[0] = 0.0;
 64     count[1] = 0.0;
 65     count[2] = 0.0;
 66     count[3] = 0.0;
 67     count[4] = 0.0;
 68     count[5] = 0.0;
 69     count[6] = 0.0;
 70     count[7] = 0.0;
 71 
 72 /* old method for region of interest defined from two of three rois
 73     tv_get_roi( xcoreg_tv_get(), &timptrlz, &timptrly, &timptruz, &timptruy);
 74     nimptrlz = (int)timptrlz;
 75     nimptruz = (int)timptruz;
 76     nimptrly = (int)timptrly;
 77     nimptruy = (int)timptruy;
 78     tv_get_roi( ycoreg_tv_get(), &timptrlx, &timptrlz, &timptrux, &timptruz);
 79     nimptrlx = (int)timptrlx;
 80     nimptrux = (int)timptrux;
 81     if (timptrlz>nimptrlz) nimptrlz = (int)timptrlz;
 82     if (timptruz<nimptruz) nimptruz = (int)timptruz;
 83     tv_get_roi( zcoreg_tv_get(), &timptrlx, &timptrly, &timptrux, &timptruy);
 84     if (timptrlx>nimptrlx) nimptrlx = (int)timptrlx;
 85     if (timptrux<nimptrux) nimptrux = (int)timptrux;
 86     if (timptrly>nimptrly) nimptrly = (int)timptrly;
 87     if (timptruy<nimptruy) nimptruy = (int)timptruy;
 88 */
 89     tv_get_roi( xcoreg_tv_get(), &timptrlz, &timptrly, &timptruz, &timptruy);
 90     nimptrlz = (int)timptrlz;
 91     nimptruz = (int)timptruz;
 92     nimptrly = (int)timptrly;
 93     nimptruy = (int)timptruy;
 94     nimptrlx = (int)0.0;
 95     nimptrux = (int)0.0;
 96 
 97 
 98     for (k=imptrlz;k<imptruz;k++)
 99     {
100     for (i=imptrly;i<nimptruy;i++)
101     {
102        for (j=imptrlx;j<imptrux;j++)
103        {
104            posi.el[0] = ((float)j+0.5 -xcentre)*nxscale;
105            posi.el[1] = ((float)i+0.5 -ycentre)*nyscale;
106            posi.el[2] = ((float)k+0.5 -zcentre)*nzscale;
107            post.el[0] = coreg_c.el[0] + vec3_dot(posi,ex)/xscale;
108            post.el[1] = coreg_c.el[1] + vec3_dot(posi,ey)/yscale;
109            post.el[2] = coreg_c.el[2] + vec3_dot(posi,ez)/zscale;
110            if (tina_int(post.el[0])>=imptrlx && tina_int(post.el[0])<imptrux
111             && tina_int(post.el[1])>=imptrly && tina_int(post.el[1])<imptruy
112             && tina_int(post.el[2])>=imptrlz && tina_int(post.el[2])<imptruz )
113            {
114               if(nearest_pixel(imptrs,post)>0.0)
115               {
116                  if (k<nimptrlz) nimptrlz = k;
117                  if (k>nimptruz) nimptruz = k;
118                  if (i<nimptrly) nimptrly = i;
119                  if (j<nimptrlx) nimptrlx = j;
120                  if (j>nimptrux) nimptrux = j;
121               }
122            }
123        }
124     }
125     }
126     for (k=nimptrlz;k<nimptruz;k++)
127     {
128     for (i=nimptrly;i<nimptruy;i++)
129     {
130        for (j=nimptrlx;j<nimptrux;j++)
131        {
132            posi.el[0] = ((float)j+0.5 -xcentre)*nxscale;
133            posi.el[1] = ((float)i+0.5 -ycentre)*nyscale;
134            posi.el[2] = ((float)k+0.5 -zcentre)*nzscale;
135            post.el[0] = coreg_c.el[0] + vec3_dot(posi,ex)/xscale;
136            post.el[1] = coreg_c.el[1] + vec3_dot(posi,ey)/yscale;
137            post.el[2] = coreg_c.el[2] + vec3_dot(posi,ez)/zscale;
138            if (tina_int(post.el[0])>=imptrlx && tina_int(post.el[0])<imptrux
139             && tina_int(post.el[1])>=imptrly && tina_int(post.el[1])<imptruy
140             && tina_int(post.el[2])>=imptrlz && tina_int(post.el[2])<imptruz )
141            {
142               if (posi.el[0]<
143                  (float)(nimptrlx+nimptrux+1.0-2.0*xcentre)*nxscale/2.0)
144               {
145                   if (posi.el[1]<
146                      (float)(nimptrly+nimptruy+1.0-2.0*ycentre)*nyscale/2.0)
147                   {
148                        if (posi.el[2]<
149                           (float)(nimptrlz+nimptruz+1.0-2.0*zcentre)*nzscale/2.0)
150                           count[0] += nearest_pixel(imptrs,post);
151                        else
152                           count[1] += nearest_pixel(imptrs,post);
153                   }
154                   else
155                   {
156                        if (posi.el[2]<
157                           (float)(nimptrlz+nimptruz+1.0-2.0*zcentre)*nzscale/2.0)
158                           count[2] += nearest_pixel(imptrs,post);
159                        else
160                           count[3] += nearest_pixel(imptrs,post);
161                   }
162               }
163               else
164               {
165                   if (posi.el[1]<
166                      (float)(nimptrly+nimptruy+1.0-2.0*ycentre)*nyscale/2.0)
167                   {
168                        if (posi.el[2]<
169                           (float)(nimptrlz+nimptruz+1.0-2.0*zcentre)*nzscale/2.0)
170                           count[4] += nearest_pixel(imptrs,post); 
171                        else
172                           count[5] += nearest_pixel(imptrs,post);
173                   }
174                   else
175                   {
176                       if (posi.el[2]<
177                          (float)(nimptrlz+nimptruz+1.0-2.0*zcentre)*nzscale/2.0)
178                           count[6] += nearest_pixel(imptrs,post);
179                       else
180                           count[7] += nearest_pixel(imptrs,post);
181                   }
182               }
183            }
184        }
185     }
186     }
187 
188     format(" --- %f --+ %f \n",count[0],count[1]);
189     format(" -+- %f -++ %f \n",count[2],count[3]);
190     format(" +-- %f +-+ %f \n",count[4],count[5]);
191     format(" ++- %f +++ %f \n",count[6],count[7]);
192     format(" x voxels %d, y voxels %d, z voxels %d \n", nimptrux-nimptrlx,
193                                                         nimptruy-nimptrly,
194                                                         nimptruz-nimptrlz )
195 ;
196 }
197 

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