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/medSroi_alloc.c,v $
23 * Date : $Date: 2004/03/10 14:56:22 $
24 * Version : $Revision: 1.7 $
25 * CVS Id : $Id: medSroi_alloc.c,v 1.7 2004/03/10 14:56:22 neil Exp $
26 *
27 * Author : Legacy TINA
28 *
29 */
30 /**
31 * @file
32 * @brief Model allocation functions for sroi functionality
33 *
34 *********
35 */
36
37 #if HAVE_CONFIG_H
38 # include <config.h>
39 #endif
40
41 #include "medSroi_alloc.h"
42
43 #include <tina/sys/sysDef.h>
44 #include <tina/sys/sysPro.h>
45 #include <tina/math/mathPro.h>
46 #include <tina/image/imgDef.h>
47 #include <tina/image/imgPro.h>
48 #include <tina/medical/med_SroiDef.h>
49
50
51
52 Model *model_alloc(int nRows, int nPoints, int nOuter, int nProf)
53 {
54 Model *mdl = NULL;
55 unsigned int i, ng;
56
57 ng = nPoints * (2 * nProf - 1);
58
59 if ((mdl = (Model *) ralloc(sizeof(Model))) == NULL)
60 {
61 error(" memory allocation failure ", non_fatal);
62 return (NULL);
63 }
64 mdl->P_Evec = (Matrix **) pvector_alloc(0, nPoints);
65 mdl->P_Eval = (Vector **) pvector_alloc(0, nPoints);
66
67 mdl->m = matrix_alloc(nRows, nPoints, matrix_full, double_v);
68 mdl->profile = matrix_alloc(nPoints, 2 * nProf - 1, matrix_full, float_v);
69 mdl->g_profile = matrix_alloc(nPoints, 2 * nProf - 1, matrix_full, double_v);
70 mdl->alpha = vector_alloc(nPoints, double_v);
71 mdl->maxgrad = vector_alloc(nPoints, int_v);
72 mdl->M_Evec = matrix_alloc(2 * nPoints, 2 * nPoints, matrix_full, double_v);
73 mdl->M_Eval = vector_alloc(2 * nPoints, double_v);
74 mdl->G_Evec = matrix_alloc(ng, nPoints, matrix_full, double_v);
75 mdl->G_Eval = vector_alloc(nPoints, double_v);
76
77 for (i = 0; i < nPoints; i++)
78 {
79 mdl->P_Evec[i] = matrix_alloc(2 * nProf - 1, 2 * nProf - 1, matrix_full, double_v);
80 mdl->P_Eval[i] = vector_alloc(2 * nProf - 1, double_v);
81 }
82
83 mdl->m_weight = vector_alloc(2 * nPoints, double_v);
84 mdl->p_weight = matrix_alloc(nPoints, 2 * nProf - 1, matrix_full, double_v);
85
86 mdl->c = nPoints;
87 mdl->r = nRows;
88 mdl->o = nOuter;
89 mdl->vsize = nProf;
90
91 return (mdl);
92 }
93
94 void model_free(Model * mdl)
95 {
96 int i;
97
98 if (mdl == NULL)
99 return;
100
101 matrix_free(mdl->m);
102 matrix_free(mdl->profile);
103 matrix_free(mdl->g_profile);
104 vector_free(mdl->alpha);
105 vector_free(mdl->maxgrad);
106 matrix_free(mdl->M_Evec);
107 vector_free(mdl->M_Eval);
108 matrix_free(mdl->G_Evec);
109 vector_free(mdl->G_Eval);
110 for (i = 0; i < mdl->c; i++)
111 {
112 matrix_free(mdl->P_Evec[i]);
113 vector_free(mdl->P_Eval[i]);
114 }
115 vector_free(mdl->m_weight);
116 matrix_free(mdl->p_weight);
117 rfree(mdl);
118 }
119
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.