**
** 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
**
** 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
cout << " ny Number of pixels Y-axis" << endl;
cout << " --phantom Phantom to use for projection" << endl;
cout << " herman Herman head phantom" << endl;
cout << " ny Number of pixels Y-axis" << endl;
cout << " --phantom Phantom to use for projection" << endl;
cout << " herman Herman head phantom" << endl;
cout << " rowland Rowland head phantom" << endl;
cout << " browland Bordered Rowland head phantom" << endl;
cout << " unitpulse Unit pulse phantom" << endl;
cout << " rowland Rowland head phantom" << endl;
cout << " browland Bordered Rowland head phantom" << endl;
cout << " unitpulse Unit pulse phantom" << endl;
phm2if_main (int argc, char* argv[])
{
ImageFile* imGlobal = NULL;
phm2if_main (int argc, char* argv[])
{
ImageFile* imGlobal = NULL;
- int opt_phmnum = -1;
- FilterType opt_filter = static_cast<FilterType>(-1);
- DomainType opt_filter_domain = D_SPATIAL;
+ string optPhmName = Phantom::PHM_HERMAN_STR;
+ string optFilterName;
+ string optDomainName = SignalFilter::DOMAIN_SPATIAL_STR;
char *endstr, *endptr;
double opt_filter_param = 1;
double opt_filter_bw = 1.;
int opt_trace = TRACE_NONE;
char *endstr, *endptr;
double opt_filter_param = 1;
double opt_filter_bw = 1.;
int opt_trace = TRACE_NONE;
#ifdef HAVE_MPI
ImageFile* imLocal = NULL;
MPIWorld mpiWorld (argc, argv);
#ifdef HAVE_MPI
ImageFile* imLocal = NULL;
MPIWorld mpiWorld (argc, argv);
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
char *endptr = NULL;
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
char *endptr = NULL;
- strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
- phm = phm_create_from_file(opt_phmfilename);
-#ifdef HAVE_MPI
- if (mpiWorld.getRank() == 0)
- cerr << "Can't use phantom from file in MPI mode" << endl;
- return (1);
-#endif
+ opt_phmFileName = optarg;
break;
case O_FILTER_BW:
opt_filter_bw = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
break;
case O_FILTER_BW:
opt_filter_bw = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
opt_filter_param = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
opt_filter_param = strtod(optarg, &endptr);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
opt_nsample = strtol(optarg, &endptr, 10);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
opt_nsample = strtol(optarg, &endptr, 10);
endstr = optarg + strlen(optarg);
if (endptr != endstr) {
- if (phm == NULL && opt_phmnum == -1 && opt_filter == -1) {
- cerr << "No phantom defined" << endl;
+ if (optPhmName == "" && optFilterName == "" && opt_phmFileName == "") {
+ cerr << "No phantom defined" << endl << endl;
opt_nx = strtol(argv[optind+1], &endptr, 10);
endstr = argv[optind+1] + strlen(argv[optind+1]);
if (endptr != endstr) {
opt_nx = strtol(argv[optind+1], &endptr, 10);
endstr = argv[optind+1] + strlen(argv[optind+1]);
if (endptr != endstr) {
phm2if_usage(argv[0]);
return (1);
}
opt_ny = strtol(argv[optind+2], &endptr, 10);
endstr = argv[optind+2] + strlen(argv[optind+2]);
if (endptr != endstr) {
phm2if_usage(argv[0]);
return (1);
}
opt_ny = strtol(argv[optind+2], &endptr, 10);
endstr = argv[optind+2] + strlen(argv[optind+2]);
if (endptr != endstr) {
- snprintf(str, sizeof(str), "nx=%d, ny=%d, nsample=%d, ", opt_nx, opt_ny, opt_nsample);
- if (opt_phmfilename[0]) {
- strncat(str, "phantom=", sizeof(str));
- strncat(str, opt_phmfilename, sizeof(str));
+ ostringstream oss;
+ oss << "phm2if: nx=" << opt_nx << ", ny=" << opt_ny << ", nsample=" << opt_nsample << ", ";
+ if (opt_phmFileName != "")
+ oss << "phantom=" << opt_phmFileName;
+ else if (optPhmName != "")
+ oss << "phantom=" << optPhmName;
+ else if (optFilterName != "") {
+ oss << "filter=" << optFilterName << " - " << optDomainName;
- else if (opt_phmnum != -1) {
- strncat(str, "phantom=", sizeof(str));
- strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
- }
- else if (opt_filter != -1) {
- strncat(str, "filter=", sizeof(str));
- strncat(str, name_of_filter(opt_filter), sizeof(str));
- strncat(str, " - ", sizeof(str));
- strncat(str, name_of_filter_domain(opt_filter_domain), sizeof(str));
+ if (opt_desc != "")
+ oss << ": " << opt_desc;
+ opt_desc = oss.str();
+
+ if (optPhmName != "") {
+ phm.createFromPhantom (optPhmName.c_str());
+ if (phm.fail()) {
+ cout << phm.failMessage() << endl << endl;
+ phm2if_usage(argv[0]);
+ return (1);
+ }
- if (opt_desc[0]) {
- strncat(str, ": ", sizeof(str));
- strncat(str, opt_desc, sizeof(str));
+
+ if (opt_phmFileName != "") {
+ phm.createFromFile(opt_phmFileName.c_str());
+#ifdef HAVE_MPI
+ if (mpiWorld.getRank() == 0)
+ cerr << "Can't use phantom from file in MPI mode" << endl;
+ return (1);
+#endif
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_nx, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_ny, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_nsample, 1, MPI::INT, 0);
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_nx, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_ny, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_nsample, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_phmnum, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_filter, 1, MPI::INT, 0);
- mpiWorld.getComm().Bcast (&opt_filter_domain, 1, MPI::INT, 0);
mpiWorld.getComm().Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
mpiWorld.getComm().Bcast (&opt_filter_bw, 1, MPI::DOUBLE, 0);
mpiWorld.getComm().Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
mpiWorld.getComm().Bcast (&opt_filter_bw, 1, MPI::DOUBLE, 0);
- imGlobal = new ImageFile (opt_outfile, opt_nx, opt_ny);
- imGlobal->fileCreate();
+ imGlobal = new ImageFile (opt_nx, opt_ny);
- imGlobal = new ImageFile (opt_outfile, opt_nx, opt_ny);
- imGlobal->fileCreate ();
-#endif
-
- if (opt_phmnum >= 0)
- phm = phm_create (opt_phmnum);
-
-#ifdef HAVE_MPI
- else {
- if (mpiWorld.getRank() == 0)
- cerr << "phmnum < 0" << endl;
- exit(1);
- }
+ imGlobal = new ImageFile (opt_nx, opt_ny);
- image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+ imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
- TimerMPI timerRasterize (mpiWorld.getComm());
- phm_to_imagefile (phm, *imLocal, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits(), opt_nsample, opt_trace);
+ TimerCollectiveMPI timerRasterize (mpiWorld.getComm());
+ phm.convertToImagefile (*imLocal, opt_nsample, opt_trace, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits());
mpi_gather_image (mpiWorld, imGlobal, imLocal, opt_debug);
if (opt_verbose)
timerGather.timerEndAndReport ("Time to gather image");
}
#else
v = imGlobal->getArray ();
mpi_gather_image (mpiWorld, imGlobal, imLocal, opt_debug);
if (opt_verbose)
timerGather.timerEndAndReport ("Time to gather image");
}
#else
v = imGlobal->getArray ();
- } else if (opt_filter != -1) {
- image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+ } else if (optFilterName != "") {
+ imGlobal->filterResponse (optDomainName.c_str(), opt_filter_bw, optFilterName.c_str(), opt_filter_param);
- phm_to_imagefile (phm, *imGlobal, 0, opt_nx, opt_nsample, opt_trace);
+ phm.convertToImagefile (*imGlobal, opt_nsample, opt_trace);
- imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc, calctime);
- imGlobal->fileClose ();
+ imGlobal->labelAdd (Array2dFileLabel::L_HISTORY, opt_desc.c_str(), calctime);
+ imGlobal->fileWrite (opt_outfile);
scanf ("%d", &nscale);
printf ("Enter minimum and maximum densities (min, max): ");
scanf ("%lf %lf", &dmin, &dmax);
scanf ("%d", &nscale);
printf ("Enter minimum and maximum densities (min, max): ");
scanf ("%lf %lf", &dmin, &dmax);
- image_display_scale (*imGlobal, nscale, dmin, dmax);
+ imGlobal->displayScaling (nscale, dmin, dmax);
- return (phm2if_main(argc, argv));
+ int retval = 1;
+
+ try {
+ retval = phm2if_main(argc, argv);
+ } catch (exception e) {
+ cerr << "Exception: " << e.what() << endl;
+ } catch (...) {
+ cerr << "Unknown exception" << endl;
+ }
+
+ return (retval);