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.2 2000/06/18 10:27:11 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 * pj2if.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 pj2if_usage (const char *program)
52 cout << "usage: " << fileBasename(program) << " in-proj-file out-if-file [OPTIONS]" << endl;
53 cout << "Converts a projection file to a IF file" << endl;
55 cout << " --verbose Verbose mode" << endl;
56 cout << " --version Print version" << endl;
57 cout << " --help Print this help message" << endl;
63 pj2if_main (const int argc, char *const argv[])
65 char *pj_name, *im_name;
67 bool opt_verbose = false;
72 int c = getopt_long (argc, argv, "", my_options, NULL);
83 cout << "Version " << VERSION << endl;
85 cout << "Unknown version number" << endl;
98 if (argc - optind != 2) {
103 pj_name = argv[optind];
104 im_name = argv[optind + 1];
107 if (! pj.read (pj_name)) {
108 sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name);
115 ImageFile im (im_name, pj.nDet(), pj.nView());
117 ImageFileArray v = im.getArray();
119 for (iy = 0; iy < pj.nView(); iy++)
121 DetectorArray& detarray = pj.getDetectorArray (iy);
122 const DetectorValue* detval = detarray.detValues();
123 for (ix = 0; ix < pj.nDet(); ix++)
125 v[ix][iy] = detval[ix];
130 im.arrayDataWrite ();
131 im.labelAdd (Array2dFileLabel::L_HISTORY, pj.remark(), pj.calcTime());
132 im.labelAdd (Array2dFileLabel::L_HISTORY, "Conversion from .pj to .if");
141 main (const int argc, char *const argv[])
143 return (pj2if_main(argc, argv));