** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.cpp,v 1.13 2000/06/22 10:17:28 kevin Exp $
+** $Id: ctrec.cpp,v 1.14 2000/06/25 17:32:24 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
int
ctrec_main (int argc, char * argv[])
{
- ImageFile *imGlobal = NULL;
Projections projGlobal;
- char *pj_name, *im_filename = NULL;
+ ImageFile* imGlobal = NULL;
+ char* filenameProj = NULL;
+ char* filenameImage = NULL;
string remark;
char *endptr;
- int opt_verbose = 0;
- int opt_debug = 0;
- int opt_trace = TRACE_NONE;
- double opt_filter_param = 1;
- string optFilterName = "abs_bandlimit";
- string optInterpName = "linear";
- string optBackprojName = "idiff2";
- int opt_interp_param = 1;
+ int optVerbose = 0;
+ int optDebug = 0;
+ int optTrace = TRACE_NONE;
+ double optFilterParam = -1;
+ string optFilterName = SignalFilter::FILTER_ABS_BANDLIMIT_STR;
+ string optInterpName = Backprojector::INTERP_LINEAR_STR;
+ string optBackprojName = Backprojector::BPROJ_IDIFF2_STR;
+ // string optFilterMethodName = SignalFilter::FILTER_METHOD_CONVOLUTION_STR;
+ int optInterpParam = 1;
int nx, ny;
#ifdef HAVE_MPI
- ImageFile *imLocal;
+ ImageFile* imLocal;
int mpi_nview, mpi_ndet;
double mpi_detinc, mpi_rotinc, mpi_phmlen;
MPIWorld mpiWorld (argc, argv);
optBackprojName = optarg;
break;
case O_FILTER_PARAM:
- opt_filter_param = strtod(optarg, &endptr);
+ optFilterParam = strtod(optarg, &endptr);
if (endptr != optarg + strlen(optarg)) {
ctrec_usage(argv[0]);
}
break;
case O_VERBOSE:
- opt_verbose = 1;
+ optVerbose = 1;
break;
case O_DEBUG:
- opt_debug = 1;
+ optDebug = 1;
break;
case O_TRACE:
- if ((opt_trace = opt_set_trace(optarg)) < 0) {
+ if ((optTrace = opt_set_trace(optarg)) < 0) {
ctrec_usage(argv[0]);
return (1);
}
return (1);
}
- pj_name = argv[optind];
+ filenameProj = argv[optind];
- im_filename = argv[optind + 1];
+ filenameImage = argv[optind + 1];
nx = strtol(argv[optind + 2], &endptr, 10);
ny = strtol(argv[optind + 3], &endptr, 10);
ostringstream filterDesc;
- if (opt_filter_param >= 0)
- filterDesc << optFilterName << ": alpha=" << opt_filter_param;
+ if (optFilterParam >= 0)
+ filterDesc << optFilterName << ": alpha=" << optFilterParam;
else
filterDesc << optFilterName;
label << "Reconstruct: " << nx << "x" << ny << ", " << filterDesc.str() << ", " << optInterpName << ", " << optBackprojName;
remark = label.str();
- if (opt_verbose)
+ if (optVerbose)
cout << "Remark: " << remark << endl;
#ifdef HAVE_MPI
}
#ifdef HAVE_MPI
if (mpiWorld.getRank() == 0) {
- projGlobal.read (pj_name);
- if (opt_verbose)
+ projGlobal.read (filenameProj);
+ if (optVerbose)
projGlobal.printScanInfo();
mpi_ndet = projGlobal.nDet();
mpiWorld.BcastString (optBackprojName);
mpiWorld.BcastString (optFilterName);
mpiWorld.BcastString (optInterpName);
- mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
- mpiWorld.getComm().Bcast (&opt_interp_param, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optVerbose, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optDebug, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optTrace, 1, MPI::INT, 0);
+ mpiWorld.getComm().Bcast (&optFilterParam, 1, MPI::DOUBLE, 0);
+ mpiWorld.getComm().Bcast (&optInterpParam, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&mpi_ndet, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&mpi_nview, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&mpi_detinc, 1, MPI::DOUBLE, 0);
mpiWorld.getComm().Bcast (&mpi_rotinc, 1, MPI::DOUBLE, 0);
mpiWorld.getComm().Bcast (&nx, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&ny, 1, MPI::INT, 0);
- if (opt_verbose)
+ if (optVerbose)
timerBcast.timerEndAndReport ("Time to broadcast variables");
mpiWorld.setTotalWorkUnits (mpi_nview);
projLocal.setRotInc (mpi_rotinc);
TimerCollectiveMPI timerScatter (mpiWorld.getComm());
- ScatterProjectionsMPI (mpiWorld, projGlobal, projLocal, opt_debug);
- if (opt_verbose)
+ ScatterProjectionsMPI (mpiWorld, projGlobal, projLocal, optDebug);
+ if (optVerbose)
timerScatter.timerEndAndReport ("Time to scatter projections");
if (mpiWorld.getRank() == 0) {
- imGlobal = new ImageFile (im_filename, nx, ny);
+ imGlobal = new ImageFile (filenameImage, nx, ny);
imGlobal->fileCreate();
}
imLocal = new ImageFile (nx, ny);
#else
- projGlobal.read (pj_name);
- if (opt_verbose)
+ projGlobal.read (filenameProj);
+ if (optVerbose)
projGlobal.printScanInfo();
- imGlobal = new ImageFile (im_filename, nx, ny);
+ imGlobal = new ImageFile (filenameImage, nx, ny);
imGlobal->fileCreate();
#endif
#ifdef HAVE_MPI
TimerCollectiveMPI timerReconstruct (mpiWorld.getComm());
- projLocal.reconstruct (*imLocal, optFilterName.c_str(), opt_filter_param, optInterpName.c_str(), opt_interp_param, optBackprojName.c_str(), opt_trace);
- if (opt_verbose)
+ projLocal.reconstruct (*imLocal, optFilterName.c_str(), optFilterParam, optInterpName.c_str(), optInterpParam, optBackprojName.c_str(), optTrace);
+ if (optVerbose)
timerReconstruct.timerEndAndReport ("Time to reconstruct");
TimerCollectiveMPI timerReduce (mpiWorld.getComm());
ReduceImageMPI (mpiWorld, imLocal, imGlobal);
- if (opt_verbose)
+ if (optVerbose)
timerReduce.timerEndAndReport ("Time to reduce image");
#else
- projGlobal.reconstruct (*imGlobal, optFilterName.c_str(), opt_filter_param, optInterpName.c_str(), opt_interp_param, optBackprojName.c_str(), opt_trace);
+ projGlobal.reconstruct (*imGlobal, optFilterName.c_str(), optFilterParam, optInterpName.c_str(), optInterpParam, optBackprojName.c_str(), optTrace);
#endif
#ifdef HAVE_MPI
imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, projGlobal.remark(), projGlobal.calcTime());
imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, remark.c_str(), calcTime);
imGlobal->fileClose ();
- if (opt_verbose)
+ if (optVerbose)
cout << "Run time: " << calcTime << " seconds" << endl;
}
#ifdef HAVE_MPI
//////////////////////////////////////////////////////////////////////////////////////
#ifdef HAVE_MPI
-static void ScatterProjectionsMPI (MPIWorld& mpiWorld, Projections& projGlobal, Projections& projLocal, const int opt_debug)
+static void ScatterProjectionsMPI (MPIWorld& mpiWorld, Projections& projGlobal, Projections& projLocal, const int optDebug)
{
if (mpiWorld.getRank() == 0) {
for (int iProc = 0; iProc < mpiWorld.getNumProcessors(); iProc++) {