X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tools%2Fphm2pj.cpp;h=1b08de1c8071785f5f546f4f32288766d586a743;hb=HEAD;hp=dc045f411df43bd29a05a8d10b23148e12cd1dac;hpb=1a050c98763fbbc0662731b0b76953acede6f5d7;p=ctsim.git diff --git a/tools/phm2pj.cpp b/tools/phm2pj.cpp index dc045f4..2bd7e3f 100644 --- a/tools/phm2pj.cpp +++ b/tools/phm2pj.cpp @@ -7,9 +7,7 @@ ** Date Started: 1984 ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id$ +** Copyright (C) 1983-2009 Kevin Rosenberg ** ** 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 @@ -29,13 +27,14 @@ #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}, @@ -64,12 +63,14 @@ phm2pj_usage (const char *program) 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"; @@ -108,6 +109,7 @@ phm2pj_main (int argc, char* const argv[]) std::string opt_desc; std::string optPhmName; std::string optPhmFileName; + std::string optImageFileName; int opt_ndet; int opt_nview; int opt_offsetview = 0; @@ -122,6 +124,7 @@ phm2pj_main (int argc, char* const argv[]) double opt_rotangle = -1; char* endptr = NULL; char* endstr; + UNUSED(opt_debug); #ifdef HAVE_MPI MPIWorld mpiWorld (argc, argv); @@ -145,6 +148,9 @@ phm2pj_main (int argc, char* const argv[]) case O_PHMFILE: optPhmFileName = optarg; break; + case O_IMAGEFILE: + optImageFileName = optarg; + break; case O_VERBOSE: opt_verbose = 1; break; @@ -245,11 +251,19 @@ phm2pj_main (int argc, char* const argv[]) } } - 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); @@ -279,32 +293,39 @@ phm2pj_main (int argc, char* const argv[]) } 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()) { + desc << "phm2pj: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", OffsetView =" << opt_offsetview << ", Geometry=" << optGeometryName << ", "; + + 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