2 ***********************************************************
3 $SNARK_Header: S N A R K 1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/read_eval_phantom1.c $
5 $LastChangedRevision: 92 $
6 $Date: 2014-07-02 17:46:48 -0400 (Wed, 02 Jul 2014) $
8 ***********************************************************
10 Previously part of SuperSNARK
13 /* ------------------------- read_eval_phantom1.c -------------------------
15 This function reads from the eval file the abnormality index for all
16 the structures in the phantom.
21 numstr - number of structures in phantom.
22 phantom - array of length numstr containing the average pixel values (i.e the
23 abnormality index) for each structure in the phantom.
24 regions - array of length numstr containing the structure numbers
25 strarea - array of length numstr containing the area (i.e number of pixels)
30 #include "experimenter.h"
32 #include "read_eval_phantom1.h"
34 void read_eval_phantom1(int** regions, int* numstr, double** phantom, int** strarea)
36 int reg, area, count = 0;
38 char string[MAXLINESIZE];
41 if ((evalfile = fopen("eval", "r")) == NULL)
43 errorc("in read_eval_phantom1.c: error in opening file ", "eval");
47 { /* Read eval file until first line of numbers is reached
48 then break from while loop */
50 fgets(string, sizeof(string), evalfile);
51 if (sscanf(string, "%d %d %lf", ®, &area, &average) == 3)
56 /* Allocate memory for the arrays phantom, strarea and
57 regions. Store abnormality index, area and structure
58 number for the first line (from previous while loop).
59 Count is a counter for the number of structures read
62 *phantom = (double *) malloc(sizeof(double));
63 *regions = (int *) malloc(sizeof(int));
64 *strarea = (int *) malloc(sizeof(int));
65 if ((*phantom == NULL) || (*regions == NULL))
66 errorc("memory allocation failed in ", "read_eval_phantom.c");
67 (*phantom)[count] = average;
68 (*strarea)[count] = area;
69 (*regions)[count] = reg;
73 { /* Read in abnormality indexes, areas and structure numbers
74 and allocate more memory for the new values. Break from
75 the while loop when finished */
77 fgets(string, sizeof(string), evalfile);
78 if (sscanf(string, "%d %d %lf", ®, &area, &average) == 3)
81 *phantom = (double *) realloc(*phantom, (count + 1) * sizeof(double));
82 *strarea = (int *) realloc(*strarea, (count + 1) * sizeof(int));
83 *regions = (int *) realloc(*regions, (count + 1) * sizeof(int));
84 if (((*phantom) == NULL) || ((*regions) == NULL) || ((*strarea) == NULL))
86 errorc("memory reallocation failed in ", "read_eval_phantom.c");
89 (*phantom)[count] = average;
90 (*strarea)[count] = area;
91 (*regions)[count] = reg;