#include "timer.h"
-enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_PHMFILE, O_GEOMETRY, O_FOCAL_LENGTH, O_CENTER_DETECTOR_LENGTH,
+enum { O_PHANTOM, O_DESC, O_NRAY, O_ROTANGLE, O_PHMFILE, O_IMAGEFILE, O_GEOMETRY, O_FOCAL_LENGTH, O_CENTER_DETECTOR_LENGTH,
O_VIEW_RATIO, O_SCAN_RATIO, O_OFFSETVIEW, O_TRACE, O_VERBOSE, O_HELP, O_DEBUG, O_VERSION };
static struct option phm2pj_options[] =
{
{"phantom", 1, 0, O_PHANTOM},
{"phmfile", 1, 0, O_PHMFILE},
+ {"imagefile", 1, 0, O_IMAGEFILE},
{"desc", 1, 0, O_DESC},
{"nray", 1, 0, O_NRAY},
{"rotangle", 1, 0, O_ROTANGLE},
std::cout << " outfile Name of output file for projections\n";
std::cout << " ndet Number of detectors\n";
std::cout << " nview Number of rotated views\n";
+ std::cout << " SELECT PHANTOM Use either --phantom, --phmfile, or --imagefile\n";
std::cout << " --phantom Phantom to use for projection\n";
std::cout << " herman Herman head phantom\n";
std::cout << " shepp-logan Shepp-Logan head phantom\n";
std::cout << " unit-pulse Unit pulse phantom\n";
std::cout << " --phmfile Get Phantom from phantom file\n";
- std::cout << " --desc Description of raysum\n";
+ std::cout << " --imagefile Get Phantom from imagefile\n";
+ std::cout << " --desc Add description for projection file\n";
std::cout << " --nray Number of rays per detector (default = 1)\n";
std::cout << " --rotangle Angle to rotate view through (fraction of a circle)\n";
std::cout << " (default = select appropriate for geometry)\n";
std::string opt_desc;
std::string optPhmName;
std::string optPhmFileName;
+ std::string optImageFileName;
int opt_ndet;
int opt_nview;
int opt_offsetview = 0;
double opt_rotangle = -1;
char* endptr = NULL;
char* endstr;
+ UNUSED(opt_debug);
#ifdef HAVE_MPI
MPIWorld mpiWorld (argc, argv);
case O_PHMFILE:
optPhmFileName = optarg;
break;
+ case O_IMAGEFILE:
+ optImageFileName = optarg;
+ break;
case O_VERBOSE:
opt_verbose = 1;
break;
}
}
- if (optPhmName == "" && optPhmFileName == "") {
+ if (optPhmName.empty() && optPhmFileName.empty() && optImageFileName.empty()) {
std::cerr << "No phantom defined\n" << std::endl;
phm2pj_usage(argv[0]);
return (1);
}
+ if ((! optPhmName.empty() && !optPhmFileName.empty()) ||
+ (! optPhmName.empty() && !optImageFileName.empty()) ||
+ (! optPhmFileName.empty() && !optImageFileName.empty())) {
+ std::cerr << "Multiple phantoms define. Use only --phantom, --phmfile, or --imagefile\n" << std::endl;
+ phm2pj_usage(argv[0]);
+ return (1);
+ }
+
if (optind + 3 != argc) {
phm2pj_usage(argv[0]);
return (1);
std::ostringstream desc;
desc << "phm2pj: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", OffsetView =" << opt_offsetview << ", Geometry=" << optGeometryName << ", ";
- if (optPhmFileName.length()) {
+
+ if (!optPhmFileName.empty()) {
desc << "PhantomFile=" << optPhmFileName;
- } else if (optPhmName != "") {
+ } else if (!optPhmName.empty()) {
desc << "Phantom=" << optPhmName;
+ } else if (!optImageFileName.empty()) {
+ desc << "Imagefile=" << optImageFileName;
}
if (opt_desc.length()) {
desc << ": " << opt_desc;
}
opt_desc = desc.str();
- if (optPhmName != "") {
+ if (!optPhmName.empty()) {
phm.createFromPhantom (optPhmName.c_str());
if (phm.fail()) {
std::cout << phm.failMessage() << std::endl << std::endl;
phm2pj_usage(argv[0]);
return (1);
}
- }
-
- if (optPhmFileName != "") {
+ } else if (!optPhmFileName.empty()) {
#ifdef HAVE_MPI
std::cerr << "Can not read phantom from file in MPI mode\n";
return (1);
#endif
- phm.createFromFile (optPhmFileName.c_str());
+ phm.createFromPhmFile (optPhmFileName.c_str());
+ } else if (!optImageFileName.empty()) {
+#ifdef HAVE_MPI
+ std::cerr << "Can not read image from file in MPI mode\n";
+ return (1);
+#endif
+ phm.createFromImageFile (optImageFileName.c_str());
}
#ifdef HAVE_MPI