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

Linux Cross Reference
Tina5/tina-libs/tina/image/imgSeq_slice.c

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

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/image/imgSeq_slice.c,v $
 37  * Date    :  $Date: 2004/08/06 15:04:58 $
 38  * Version :  $Revision: 1.10 $
 39  * CVS Id  :  $Id: imgSeq_slice.c,v 1.10 2004/08/06 15:04:58 paul Exp $
 40  */
 41 
 42 /** 
 43  *  @file
 44  *  @brief Functions associated with sub-pixel interpolation of 3D volume data, such as
 45  *  that which can be stored in the sequence data structure. 
 46  *
 47  *  Uses various interpolation approaches including tri-linear and re-normalised Sinc interpolation.
 48  *  Routines can generate images at fixed orthogonal planes for display and other purposes.  
 49  *
 50  */
 51 
 52 
 53 #include "imgSeq_slice.h"
 54 
 55 #if HAVE_CONFIG_H
 56 #include <config.h>
 57 #endif
 58 
 59 #include <stdio.h>
 60 #include <math.h>
 61 #include <tina/sys/sysDef.h>
 62 #include <tina/sys/sysPro.h>
 63 #include <tina/math/mathDef.h>
 64 #include <tina/math/mathPro.h>
 65 #include <tina/image/imgDef.h>
 66 #include <tina/image/imgPro.h>
 67 
 68 
 69 static void ***imptrs=NULL;                                                                                     /* static data! */
 70 static int imptrlx, imptrux,imptrly, imptruy, imptrlz, imptruz;                                                 /* static data! */
 71 static int blx, bux, bly, buy, blz, buz;                                                                        /* static data! */
 72 static float (*interp)(void ***rasptrs, Vec3 pos) = NULL;                                                       /* static data! */
 73 static float (*seq_pixel)(void ***rasptrs, int z, int y, int x) = NULL;                                         /* static data! */
 74 static double (*sinc_accum)(void ***rasptrs, int z, int y, int x, float *hxp) = NULL;                           /* static data! */
 75 static int barrier=1;                                                                                           /* static data! */
 76 
 77 void ***seq_limits(int *lz, int *uz, int *ly, int *uy, int *lx, int *ux)
 78 {
 79    *lz = imptrlz;
 80    *uz = imptruz;
 81    *ly = imptrly;
 82    *uy = imptruy;
 83    *lx = imptrlx;
 84    *ux = imptrux;
 85    return(imptrs);
 86 }
 87 
 88 static float seq_cpixel(void ***rasptrs, int z, int y, int x)
 89 {
 90     char *row;
 91     row = rasptrs[z][y];
 92     return((float)row[x]);
 93 }
 94 
 95 static float seq_ucpixel(void ***rasptrs, int z, int y, int x)
 96 {
 97     unsigned char *row;
 98     row = rasptrs[z][y];
 99     return((float)row[x]);
100 }
101 
102 static float seq_spixel(void ***rasptrs, int z, int y, int x)
103 {
104     short *row;
105     row = rasptrs[z][y];
106     return((float)row[x]);
107 }
108 
109 static float seq_uspixel(void ***rasptrs, int z, int y, int x)
110 {
111     unsigned short *row;
112     row = rasptrs[z][y];
113     return((float)row[x]);
114 }
115 
116 static float seq_ipixel(void ***rasptrs, int z, int y, int x)
117 {
118     int *row;
119     row = rasptrs[z][y];
120     return((float)row[x]);
121 }
122 
123 static float seq_fpixel(void ***rasptrs,int z, int y, int x)
124 {
125     float *row;
126     row = rasptrs[z][y];
127     return((float)row[x]);
128 }
129 
130 static double sinc_accumuc(void *** rasptrs, int z, int y, int x, float *hxp)
131 {
132      unsigned char *row;
133      unsigned char *thispix;
134      double pfac;
135  
136      row = rasptrs[z][y];
137      thispix = &row[x];
138      pfac = 0.0;
139      switch(barrier)
140      {
141         case 6:
142           pfac += *(thispix++)* *(hxp++);
143           pfac += *(thispix++)* *(hxp++);
144             
145         case 5:
146           pfac += *(thispix++)* *(hxp++);
147           pfac += *(thispix++)* *(hxp++);
148             
149         case 4:
150           pfac += *(thispix++)* *(hxp++);
151           pfac += *(thispix++)* *(hxp++);
152             
153         case 3:
154           pfac += *(thispix++)* *(hxp++);
155           pfac += *(thispix++)* *(hxp++);
156             
157         case 2:
158           pfac += *(thispix++)* *(hxp++);
159           pfac += *(thispix++)* *(hxp++);
160             
161        case 1:
162          pfac += *(thispix++)* *(hxp++);
163          pfac += *(thispix++)* *(hxp++);
164          pfac += *(thispix++)* *(hxp++);
165     }       
166     return (pfac);
167 }
168 
169 static double sinc_accumc(void *** rasptrs, int z, int y, int x, float *hxp)
170 {
171      char *row;
172      char *thispix;
173      double pfac;
174 
175      row = rasptrs[z][y];
176      thispix = &row[x];
177      pfac = 0.0;
178      switch(barrier)
179      {
180         case 6:
181           pfac += *(thispix++)* *(hxp++);
182           pfac += *(thispix++)* *(hxp++);
183 
184         case 5:
185           pfac += *(thispix++)* *(hxp++);
186           pfac += *(thispix++)* *(hxp++);
187 
188         case 4:
189           pfac += *(thispix++)* *(hxp++);
190           pfac += *(thispix++)* *(hxp++);
191 
192         case 3:
193           pfac += *(thispix++)* *(hxp++);
194           pfac += *(thispix++)* *(hxp++);
195 
196         case 2:
197           pfac += *(thispix++)* *(hxp++);
198           pfac += *(thispix++)* *(hxp++);
199 
200        case 1:
201          pfac += *(thispix++)* *(hxp++);
202          pfac += *(thispix++)* *(hxp++);
203          pfac += *(thispix++)* *(hxp++);
204     }
205     return (pfac);
206 }
207 
208 static double sinc_accums(void *** rasptrs, int z, int y, int x, float *hxp)
209 {
210      short *row;
211      short *thispix;
212      double pfac;
213 
214      row = rasptrs[z][y];
215      thispix = &row[x];
216      pfac = 0.0;
217      switch(barrier)
218      {
219         case 6:
220           pfac += *(thispix++)* *(hxp++);
221           pfac += *(thispix++)* *(hxp++);
222 
223         case 5:
224           pfac += *(thispix++)* *(hxp++);
225           pfac += *(thispix++)* *(hxp++);
226 
227         case 4:
228           pfac += *(thispix++)* *(hxp++);
229           pfac += *(thispix++)* *(hxp++);
230 
231         case 3:
232           pfac += *(thispix++)* *(hxp++);
233           pfac += *(thispix++)* *(hxp++);
234 
235         case 2:
236           pfac += *(thispix++)* *(hxp++);
237           pfac += *(thispix++)* *(hxp++);
238 
239        case 1:
240          pfac += *(thispix++)* *(hxp++);
241          pfac += *(thispix++)* *(hxp++);
242          pfac += *(thispix++)* *(hxp++);
243     }
244     return (pfac);
245 }
246 
247 static double sinc_accumus(void *** rasptrs, int z, int y, int x, float *hxp)
248 {
249      unsigned short *row;
250      unsigned short *thispix;
251      double pfac;
252 
253      row = rasptrs[z][y];
254      thispix = &row[x];
255      pfac = 0.0;
256      switch(barrier)
257      {
258         case 6:
259           pfac += *(thispix++)* *(hxp++);
260           pfac += *(thispix++)* *(hxp++);
261 
262         case 5:
263           pfac += *(thispix++)* *(hxp++);
264           pfac += *(thispix++)* *(hxp++);
265 
266         case 4:
267           pfac += *(thispix++)* *(hxp++);
268           pfac += *(thispix++)* *(hxp++);
269 
270         case 3:
271           pfac += *(thispix++)* *(hxp++);
272           pfac += *(thispix++)* *(hxp++);
273 
274         case 2:
275           pfac += *(thispix++)* *(hxp++);
276           pfac += *(thispix++)* *(hxp++);
277 
278        case 1:
279          pfac += *(thispix++)* *(hxp++);
280          pfac += *(thispix++)* *(hxp++);
281          pfac += *(thispix++)* *(hxp++);
282     }
283     return (pfac);
284 }
285 
286 static double sinc_accumi(void *** rasptrs, int z, int y, int x, float *hxp)
287 {
288      int *row;
289      int *thispix;
290      double pfac;
291 
292      row = rasptrs[z][y];
293      thispix = &row[x];
294      pfac = 0.0;
295      switch(barrier)
296      {
297         case 6:
298           pfac += *(thispix++)* *(hxp++);
299           pfac += *(thispix++)* *(hxp++);
300 
301         case 5:
302           pfac += *(thispix++)* *(hxp++);
303           pfac += *(thispix++)* *(hxp++);
304 
305         case 4:
306           pfac += *(thispix++)* *(hxp++);
307           pfac += *(thispix++)* *(hxp++);
308 
309         case 3:
310           pfac += *(thispix++)* *(hxp++);
311           pfac += *(thispix++)* *(hxp++);
312 
313         case 2:
314           pfac += *(thispix++)* *(hxp++);
315           pfac += *(thispix++)* *(hxp++);
316 
317        case 1:
318          pfac += *(thispix++)* *(hxp++);
319          pfac += *(thispix++)* *(hxp++);
320          pfac += *(thispix++)* *(hxp++);
321     }
322     return (pfac);
323 }
324 
325 static double sinc_accumf(void *** rasptrs, int z, int y, int x, float *hxp)
326 {
327      float *row;
328      float *thispix;
329      double pfac;
330 
331      row = rasptrs[z][y];
332      thispix = &row[x];
333      pfac = 0.0;
334      switch(barrier)
335      {
336         case 6:
337           pfac += *(thispix++)* *(hxp++);
338           pfac += *(thispix++)* *(hxp++);
339 
340         case 5:
341           pfac += *(thispix++)* *(hxp++);
342           pfac += *(thispix++)* *(hxp++);
343 
344         case 4:
345           pfac += *(thispix++)* *(hxp++);
346           pfac += *(thispix++)* *(hxp++);
347 
348         case 3:
349           pfac += *(thispix++)* *(hxp++);
350           pfac += *(thispix++)* *(hxp++);
351 
352         case 2:
353           pfac += *(thispix++)* *(hxp++);
354           pfac += *(thispix++)* *(hxp++);
355 
356        case 1:
357          pfac += *(thispix++)* *(hxp++);
358          pfac += *(thispix++)* *(hxp++);
359          pfac += *(thispix++)* *(hxp++);
360     }
361     return (pfac);
362 }
363 
364 
365 void seq_voxel_vtype(Vartype vtype)
366 {
367     if (vtype == char_v) seq_pixel = seq_cpixel; 
368     if (vtype == char_v) sinc_accum = sinc_accumc; 
369     if (vtype == uchar_v) seq_pixel = seq_ucpixel; 
370     if (vtype == uchar_v) sinc_accum = sinc_accumuc; 
371     if (vtype == short_v) seq_pixel = seq_spixel; 
372     if (vtype == short_v) sinc_accum = sinc_accums; 
373     if (vtype == ushort_v) seq_pixel = seq_uspixel; 
374     if (vtype == ushort_v) sinc_accum = sinc_accumus; 
375     if (vtype == int_v) seq_pixel = seq_ipixel; 
376     if (vtype == int_v) sinc_accum = sinc_accumi; 
377     if (vtype == float_v) seq_pixel = seq_fpixel; 
378     if (vtype == float_v) sinc_accum = sinc_accumf; 
379 }
380 
381 void seq_init_interp(int nblx, int nbux, int nbly, int nbuy, int nblz, int nbuz)
382 {
383    blx = nblx+barrier;
384    bux = nbux-barrier;
385    bly = nbly+barrier;
386    buy = nbuy-barrier;
387    blz = nblz+barrier;
388    buz = nbuz-barrier;
389 }
390 
391 float this_pixel(void ***rasptrs, int z, int y, int x)
392 {
393    return(seq_pixel(rasptrs,z, y, x));
394 }
395 
396 float seq_interp(void ***rasptrs, Vec3 pos)
397 {
398    return(interp(rasptrs,pos));
399 }
400 
401 float nearest_pixel(void ***rasptrs, Vec3 pos)
402 {
403     int x, y, z;
404     x = tina_int(pos.el[0]);
405     y = tina_int(pos.el[1]);
406     z = tina_int(pos.el[2]);
407     if (x<blx || x>=bux
408     ||  y<bly || y>=buy
409     ||  z<blz || z>=buz )
410        return(0.0);
411     return(seq_pixel(rasptrs,z, y, x));
412 }
413 
414 float tri_linear(void ***rasptrs, Vec3 pos)
415 {
416     float xoffset, yoffset, zoffset;
417     float cenpix,newpix,nextpix;
418     float xfac, yfac, zfac;
419     int x , y, z;
420 
421     x = tina_int(pos.el[0]);
422     y = tina_int(pos.el[1]);
423     z = tina_int(pos.el[2]);
424     if (x<blx || x>=bux 
425     ||  y<bly || y>=buy
426     ||  z<blz || z>=buz )        
427        return(0.0);
428 
429     xoffset = pos.el[0] - x - 0.5;
430     yoffset = pos.el[1] - y - 0.5;
431     zoffset = pos.el[2] - z - 0.5;
432     cenpix = seq_pixel(rasptrs,z,y,x);
433     if (zoffset<0.0) 
434     {
435       nextpix = seq_pixel(rasptrs,z-1,y,x);
436       zfac = cenpix - nextpix;
437     }
438     else
439     {
440       nextpix = seq_pixel(rasptrs,z+1,y,x);
441       zfac = nextpix - cenpix;
442     }
443 
444     if (yoffset<0.0)
445     {
446       nextpix = seq_pixel(rasptrs,z,y-1,x); 
447       yfac = cenpix -nextpix;
448     }
449     else
450     {
451       nextpix = seq_pixel(rasptrs,z,y+1,x); 
452       yfac = nextpix - cenpix;
453     }
454 
455     if (xoffset<0.0)
456     {
457       nextpix = seq_pixel(rasptrs,z,y,x-1);
458       xfac = cenpix - nextpix;
459     }
460     else
461     {
462       nextpix = seq_pixel(rasptrs,z,y,x+1);
463       xfac = nextpix - cenpix;
464     }
465     newpix = cenpix + xfac*xoffset + yfac*yoffset + zfac*zoffset;
466 
467     return(newpix);
468 }
469 
470 static float han_sinc(float delta)
471 {
472    double sinc ,phase,hanning;
473 
474    phase = PI*delta;
475    if(fabs(phase) > 0.000001) sinc = sin(phase)/phase;
476    else sinc = 1.0;
477    hanning = (0.5 + 0.5*cos(phase/(float)(1.0+barrier)));
478    return(hanning*sinc);
479 }
480 
481 static float sinc_interp(void ***rasptrs, Vec3 pos)
482 {
483     float ypos, zpos;
484     float newpix=0.0;
485     float xoffset, yoffset, zoffset;
486     float hxtot=0.0, hytot=0.0, hztot=0.0;
487     float pfac;
488     static float *hx=NULL;                                      /* static data! */
489     static float *hy=NULL, *hz =NULL;           /* static data! */
490     int i,j;
491     int x , y, z;
492 
493     x = tina_int(pos.el[0]);
494     y = tina_int(pos.el[1]);
495     z = tina_int(pos.el[2]);
496     if (x<blx || x>=bux 
497     ||  y<bly || y>=buy
498     ||  z<blz || z>=buz )        
499        return(0.0);
500    
501     xoffset = pos.el[0] - x - 0.5;
502     yoffset = pos.el[1] - y - 0.5;
503     zoffset = pos.el[2] - z - 0.5;
504     if (hx  == NULL)
505     {
506         hx = fvector_alloc(-6,7);
507         hy = fvector_alloc(-6,7);
508         hz = fvector_alloc(-6,7);
509     }
510     for (i=-barrier;i<=barrier;i++)
511     {
512        hz[i] = han_sinc(zoffset-(float)i);
513        hztot += hz[i];
514        hy[i] = han_sinc(yoffset-(float)i);
515        hytot += hy[i];
516        hx[i] = han_sinc(xoffset-(float)i);
517        hxtot += hx[i];
518     }
519     for (i=-barrier;i<=barrier;i++)
520     {
521        zpos = pos.el[2] + (float)i;
522        for (j=-barrier;j<=barrier;j++)
523        {
524           ypos = pos.el[1] + (float)j;
525           pfac = sinc_accum(rasptrs, tina_int(zpos),tina_int(ypos),
526                  tina_int(pos.el[0]-(float)barrier),&hx[-barrier]);
527           newpix += hz[i]*hy[j]*pfac;
528        }
529     }
530     return(newpix/(hxtot*hytot*hztot)); 
531 }
532 
533 /* mjs 10.10.03 changing seq_interp_choice to return the old value of the barrier, in
534    order that the barrier can be set and the reset back to original value */
535 /* Not sure whether this really needs to be done, if problematic please change back */
536 
537 int seq_interp_choice(int choice)
538 {
539   int old_val = barrier;
540 
541    if (choice == 0)
542    {
543       interp = nearest_pixel;
544       barrier = 0;
545    }
546    if (choice == 1)
547    {
548       interp = tri_linear;
549       barrier = 1;
550    }
551    if (choice ==2)
552    {
553       interp = sinc_interp;
554       barrier = 2;
555    }
556    if (choice ==3)
557    {
558       interp = sinc_interp;
559       barrier = 3;
560    }
561    if (choice ==4)
562    {
563       interp = sinc_interp;
564       barrier = 4;
565    }
566    if (choice ==5)
567    {
568       interp = sinc_interp;
569       barrier = 5;
570    }
571    if (choice ==6)
572    {
573       interp = sinc_interp;
574       barrier = 6;
575    }
576    return(old_val);
577 }
578 
579 Imrect * seq_slicez(float zslice, Imregion *within, Vec3(*proj_func)( ))
580 {
581     Vec3 post;
582     int i,j;
583     float *row1;
584     Imrect *im;
585     Imregion roi;
586 
587     if (imptrs == NULL)
588     {
589        error("no data to display in seq_slicez() \n",warning);
590        return(NULL);
591     }
592     if (within != NULL)
593          roi = *within;
594     else
595     {
596        roi_fill(&roi,imptrlx,imptrly,imptrux,imptruy);
597     }
598 
599     im = im_alloc(roi.uy-roi.ly,roi.ux-roi.lx,&roi,float_v);
600 
601     seq_init_interp(imptrlx,imptrux,
602                 imptrly,imptruy,
603                 imptrlz,imptruz);
604     for (i=roi.ly;i<roi.uy;i++)
605     {
606        row1 = (float*) IM_ROW(im,i);
607        row1 = &row1[roi.lx];
608        for (j=roi.lx;j<roi.ux;j++)
609        {
610            post = proj_func((double)j+0.5,(double)i+0.5,(double)zslice);
611            *(row1++) = interp(imptrs,post);
612        }
613     }
614     return(im);
615 }
616 
617 Imrect * seq_slicey(float slicey, Imregion *within, Vec3(*proj_func)( ))
618 {
619     Vec3 post;
620     int j,k;
621     float *row1;
622     Imrect *im;
623     Imregion roi;
624 
625     if (imptrs == NULL)
626     {
627        error("no data to display in seq_slicey() \n",warning);
628        return(NULL);
629     }
630     if (within !=NULL)
631        roi = *within;
632     else
633     {
634        roi_fill(&roi,imptrlx,imptrlz,imptrux,imptruz);
635     }
636     im = im_alloc(roi.uy-roi.ly,roi.ux-roi.lx,&roi,float_v);
637     seq_init_interp(imptrlx,imptrux,
638                 imptrly,imptruy,
639                 imptrlz,imptruz);
640 
641     for(k=roi.ly;k<roi.uy;k++)
642     {
643         row1 = (float*) IM_ROW(im,k);
644         row1 = &row1[roi.lx];
645         for (j=roi.lx;j<roi.ux;j++)
646         {
647             post = proj_func((double)j+0.5,(double)slicey,(double)k+0.5);
648 
649             *(row1++) = interp(imptrs,post);
650         }
651     }
652     return(im);
653 }
654 
655 Imrect * seq_slicex(float slicex, Imregion *within, Vec3(*proj_func)( ))
656 {
657     Vec3 post;
658     int i,j;
659     float *row1;
660     Imrect *im;
661     Imregion roi;
662 
663     if (imptrs == NULL)
664     {
665        error("no data to display in seq_slicex() \n",warning);
666        return(NULL);
667     }
668     if (within != NULL)
669        roi = *within;
670     else
671     {
672        roi_fill(&roi,imptrlz,imptrly,imptruz,imptruy);
673     }
674     im = im_alloc(roi.uy-roi.ly,roi.ux-roi.lx,&roi,float_v);
675 
676     seq_init_interp(imptrlx,imptrux,
677                 imptrly,imptruy,
678                 imptrlz,imptruz);
679 
680     for (i=roi.ly;i<roi.uy;i++)
681     {
682        row1 = (float*) IM_ROW(im,i);
683        row1 = &row1[roi.lx];
684        for (j=roi.lx;j<roi.ux;j++)
685        {
686            post = proj_func((double)slicex,(double)i+0.5,(double)j+0.5);
687            *(row1++) = interp(imptrs,post);
688        }
689     }
690     return(im);
691 }
692 
693 static int get_total_frames(Sequence *seq)
694 {
695 
696 int          count;
697   List      *im_ptr;
698 
699   if (seq == NULL)
700     return(0);
701 
702   count = seq->offset;
703 
704   if ((im_ptr = get_seq_start_el(seq)) == NULL)
705     return(count);
706 
707   while(im_ptr->next != NULL)
708     {
709 
710       im_ptr = im_ptr->next;
711       count = count +1;
712     }
713 
714   return (count);
715 }
716 
717 /* get_end_frame finds the number of the end frame of a sequence, given the start image
718    in the sequence and the number of the start image. loops over the image sequence until
719    it reaches the end, counting as it goes. */
720 int get_end_frame(Sequence *seq)
721 {
722   int          count;
723   List      *im_ptr;
724 
725   if (seq == NULL)
726     return(0);
727 
728   count = seq->offset;
729 
730   if ((im_ptr = get_seq_start_el(seq)) == NULL)
731     return(count);
732  
733   while(im_ptr->next != NULL)
734     {
735  
736       im_ptr = im_ptr->next;
737       count = count + seq->stride;
738     }
739  
740   return (count);
741 }
742 
743 
744 void ***seq_slice_init(Sequence *seq)
745 {
746     List *frame;
747     Imrect *im, *imref;
748     Imregion roi;
749     int i,j;
750 
751     if (imptrs!=NULL) parray_free(imptrs,imptrlz,imptrly,imptruz,imptruy);
752     imptrs = NULL;
753     frame = get_seq_start_el(seq);
754     if((frame==NULL)||(imref = frame->to)==NULL) return(NULL);
755     seq_voxel_vtype(imref->vtype);
756     roi = *(imref->region);
757 
758     imptrlx = roi.lx;
759     imptrux = roi.ux;
760     imptrly = roi.ly;
761     imptruy = roi.uy;
762     imptrlz = seq->offset;
763     imptruz = get_total_frames(seq) + 1;
764     imptrs = (void ***)parray_alloc(imptrlz,imptrly,imptruz,imptruy);
765     im = imref;
766     for (i=imptrlz;i<imptruz;i++)
767     {
768        for (j=imptrly;j<imptruy;j++)
769        {
770            imptrs[i][j] = (void *)IM_ROW(im,j);
771        }
772        if( frame !=NULL)
773        {
774           frame = frame->next;
775           if (frame!=NULL) im = frame->to;
776        }
777     }
778 
779         return (imptrs);
780 }
781 
782 
783 void ***imptrs_swap(void ***imptrs_new)
784 {
785         void ***imptrs_temp=NULL;
786 
787         imptrs_temp = imptrs;
788         imptrs = imptrs_new;
789         return imptrs_temp;
790 }
791 

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