1 /**********
2 *
3 * This file is part of the TINA Open Source Image Analysis Environment
4 * henceforth known as TINA
5 *
6 * TINA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation.
9 *
10 * TINA is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with TINA; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 **********
20 *
21 * Program : TINA
22 * File : $Source: /home/tina/cvs/tina-libs/tina/medical/medStim_tdata.c,v $
23 * Date : $Date: 2003/10/06 12:29:47 $
24 * Version : $Revision: 1.4 $
25 * CVS Id : $Id: medStim_tdata.c,v 1.4 2003/10/06 12:29:47 neil Exp $
26 *
27 * Notes:
28 * NAT 24.5.98->11.01.2002
29 *
30 *********
31 */
32
33 #if HAVE_CONFIG_H
34 # include <config.h>
35 #endif
36
37 #include "medStim_tdata.h"
38
39 #include <stdio.h>
40 #include <math.h>
41 #include <tina/sys/sysDef.h>
42 #include <tina/sys/sysPro.h>
43 #include <tina/math/mathDef.h>
44 #include <tina/math/mathPro.h>
45 #include <tina/image/imgDef.h>
46 #include <tina/image/imgPro.h>
47 #include <tina/medical/med_StimDef.h>
48
49
50 float *s_2d_mask_mean(void ***imptrs, Imrect *mask, Perfusion *p)
51 {
52 float *mean, area_sum;
53 int i, j, k, total;
54 double val;
55 Imregion roi;
56 if (mask!=NULL) roi = *(Imregion*)mask->region;
57 else return(NULL);
58
59
60 if ((mean = fvector_alloc(p->n1, p->n2)) == NULL)
61 return(NULL);
62
63 for (k = p->n1; k < p->n2; k++)
64 {
65 area_sum = 0.0;
66 total = 0;
67
68 for (i = roi.ly; i < roi.uy; i++)
69 {
70 for (j = roi.lx; j < roi.ux; j++)
71 {
72 IM_PIX_GET(mask, i, j, val);
73 if (val == 1)
74 {
75 area_sum += this_pixel(imptrs, k, i, j);
76 total++;
77 }
78 }
79 }
80 mean[k] = area_sum/(float)total;
81 }
82
83 return(mean);
84 }
85
86 float *s_2d_pixel_get(void ***imptrs, Vec2 v, Perfusion *p)
87 {
88 float *data;
89 int i, j, k;
90
91
92 if ((data = fvector_alloc(p->n1, p->n2)) == NULL)
93 return(NULL);
94
95 j = tina_int(vec2_x(v));
96 i = tina_int(vec2_y(v));
97
98 for (k = p->n1; k < p->n2-1; k++)
99 {
100 data[k] = 0.5*(this_pixel(imptrs, k, i, j)
101 +this_pixel(imptrs, k+1, i, j));
102 }
103 data[k] = this_pixel(imptrs, k, i, j);
104
105 return(data);
106 }
107
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.