1 /*****************************************************************************
5 ** Purpose: Convert an projection data file to an image file
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: April 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: pj2if.cpp,v 1.1 2000/06/17 20:12:15 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 * proj2if.c Convert Raysum to image
38 enum { O_VERBOSE, O_HELP, O_VERSION };
40 static struct option my_options[] =
42 {"verbose", 0, 0, O_VERBOSE},
43 {"help", 0, 0, O_HELP},
44 {"version", 0, 0, O_VERSION},
50 proj2if_usage (const char *program)
52 fprintf(stdout, "usage: %s in-proj-file out-if-file [OPTIONS]\n", fileBasename(program));
53 fprintf(stdout, "This program converts a projection file to a IF file\n");
54 fprintf(stdout, "\n");
55 fprintf(stdout, " --verbose Verbose mode\n");
56 fprintf(stdout, " --version Print version\n");
57 fprintf(stdout, " --help Print this help message\n");
63 proj2if_main (const int argc, char *const argv[])
65 char *proj_name, *im_name;
67 bool opt_verbose = false;
72 int c = getopt_long (argc, argv, "", my_options, NULL);
83 fprintf(stdout, "Version %s\n", VERSION);
85 fprintf(stderr, "Unknown version number");
90 proj2if_usage(argv[0]);
93 proj2if_usage(argv[0]);
98 if (argc - optind != 2) {
99 proj2if_usage(argv[0]);
103 proj_name = argv[optind];
104 im_name = argv[optind + 1];
107 if (! proj.read (proj_name)) {
108 sys_error (ERR_SEVERE, "Can not open projection file %s", proj_name);
113 proj.printScanInfo();
115 ImageFile im (im_name, proj.nDet(), proj.nView());
117 ImageFileArray v = im.getArray();
119 for (iy = 0; iy < proj.nView(); iy++)
121 DetectorArray& detarray = proj.getDetectorArray (iy);
122 const DetectorValue* detval = detarray.detValues();
123 for (ix = 0; ix < proj.nDet(); ix++)
125 v[ix][iy] = detval[ix];
130 im.arrayDataWrite ();
131 im.labelAdd (Array2dFileLabel::L_HISTORY, proj.remark(), proj.calcTime());
132 im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
141 main (const int argc, char *const argv[])
143 return (proj2if_main(argc, argv));