2.1.0 - 12/18/00
+ Improved pjinfo to output binary headers and view data, useful
+ when manually compiling phantoms that vary during projection
+ process. Thanks to Ian Kay for idea and code submission.
Modifications for Microsoft Visual C++ compilation.
First Microsoft Windows GUI version
Improved sorting to find median in ImageFile::statistics
Fixed core-dump bug in Array2dFile::labelsCopy() function (Ian Kay)
- Improved pjinfo to output binary headers and view data, useful
- when manually compiling phantoms that vary during projection
- process. Thanks to Ian Kay for idea and code submission.
Changed code to explicitly use std:: namespace rather than
"namespace using std" statements
Changed reconstruction dialog to fix onto smaller screens
+ Renamed if2img to ifexport
2.0.6 - 12/03/00
Fixed minor compilation problem with procsignal.h
pj2if - Converts projection data to a raw sinugram image
-if2img - Converts an image file to a variety of 8-bit and 16-bit image
+ifexport - Converts an image file to a variety of 8-bit and 16-bit image
formats
pjinfo - Show information on a projection file
Create a phantom image and viewable image file
phm2if ...
- if2img ...
+ ifexport ...
Simulate CT data collection and create a viewable image of raw projections
phm2pj ...
pj2if ...
- if2img ...
+ ifexport ...
Perform CT reconstruction and create viewable image file
pjrec ...
- if2img ...
+ ifexport ...
Display image information and comparative statistics
ifinfo ...
$window_options .= " --max $Disp_Max";
}
-my $png1_cmd = "$::bindir/if2img $phantom_fname $phantom_png $window_options --stats --format png";
-my $png2_cmd = "$::bindir/if2img $ir_fname $ir_png $window_options --stats --format png";
-my $png3_cmd = "$::bindir/if2img $pj_if_fname $pj_png --auto $auto_window_pj --stats --format png";
-my $png4_cmd = "$::bindir/if2img $sub_fname $sub_png --auto $auto_window_diff --stats --format png";
+my $png1_cmd = "$::bindir/ifexport $phantom_fname $phantom_png $window_options --stats --format png";
+my $png2_cmd = "$::bindir/ifexport $ir_fname $ir_png $window_options --stats --format png";
+my $png3_cmd = "$::bindir/ifexport $pj_if_fname $pj_png --auto $auto_window_pj --stats --format png";
+my $png4_cmd = "$::bindir/ifexport $sub_fname $sub_png --auto $auto_window_diff --stats --format png";
my $title = "CT Simulation Results";
install -s -m 755 -o 0 -g 0 tools/phm2if /usr/local/bin/phm2if
install -s -m 755 -o 0 -g 0 tools/if-1 /usr/local/bin/if-1
install -s -m 755 -o 0 -g 0 tools/if-2 /usr/local/bin/if-2
-install -s -m 755 -o 0 -g 0 tools/if2img /usr/local/bin/if2img
+install -s -m 755 -o 0 -g 0 tools/ifexport /usr/local/bin/ifexport
install -s -m 755 -o 0 -g 0 tools/if-1 /usr/local/bin/ifinfo
install -m 755 -o 0 -g 0 tools/sample-ctsim.sh /usr/local/bin/sample-ctsim.sh
/usr/local/bin/phm2if
/usr/local/bin/if-1
/usr/local/bin/if-2
-/usr/local/bin/if2img
+/usr/local/bin/ifexport
/usr/local/bin/ifinfo
/usr/local/bin/sample-ctsim.sh
-bin_PROGRAMS = pjrec phm2pj pj2if @lamprograms@ ifinfo phm2if if-1 if-2 if2img pjinfo
+bin_PROGRAMS = pjrec phm2pj pj2if @lamprograms@ ifinfo phm2if if-1 if-2 ifexport pjinfo
bin_SCRIPTS = sample-ctsim.sh
EXTRA_PROGRAMS = pjrec-lam phm2pj-lam phm2if-lam
INCLUDES=@my_includes@
phm2if_SOURCES = phm2if.cpp
phm2if_LDADD=@ctlibs@
phm2if_DEPENDENCIES=$(SOURCE_DEPEND)
-if2img_SOURCES = if2img.cpp
-if2img_LDADD=@ctlibs@
-if2img_DEPENDENCIES=$(SOURCE_DEPEND)
+ifexport_SOURCES = ifexport.cpp
+ifexport_LDADD=@ctlibs@
+ifexport_DEPENDENCIES=$(SOURCE_DEPEND)
pj2if_SOURCES = pj2if.cpp
pj2if_LDADD=@ctlibs@
pj2if_DEPENDENCIES=$(SOURCE_DEPEND)
+++ /dev/null
-/*****************************************************************************
-** FILE IDENTIFICATION
-**
-** Name: if2img.cpp
-** Purpose: Convert an image file to a viewable image
-** Programmer: Kevin Rosenberg
-** Date Started: April 2000
-**
-** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: if2img.cpp,v 1.7 2000/12/16 07:28:25 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
-** published by the Free Software Foundation.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-******************************************************************************/
-
-#include "ct.h"
-
-
-enum { O_SCALE, O_MIN, O_MAX, O_AUTO, O_CENTER, O_STATS, O_FORMAT, O_LABELS,
- O_HELP, O_VERBOSE, O_VERSION, O_DEBUG };
-
-static struct option my_options[] =
-{
- {"scale", 1, 0, O_SCALE},
- {"min", 1, 0, O_MIN},
- {"max", 1, 0, O_MAX},
- {"auto", 1, 0, O_AUTO},
- {"center", 1, 0, O_CENTER},
- {"format", 1, 0, O_FORMAT},
- {"labels", 0, 0, O_LABELS},
- {"stats", 0, 0, O_STATS},
- {"verbose", 0, 0, O_VERBOSE},
- {"debug", 0, 0, O_DEBUG},
- {"help", 0, 0, O_HELP},
- {"version", 0, 0, O_VERSION},
- {0, 0, 0, 0}
-};
-
-static const char* g_szIdStr = "$Id: if2img.cpp,v 1.7 2000/12/16 07:28:25 kevin Exp $";
-
-enum { O_AUTO_FULL, O_AUTO_STD0_1, O_AUTO_STD0_5, O_AUTO_STD1, O_AUTO_STD2, O_AUTO_STD3 };
-static const char O_AUTO_FULL_STR[]="full";
-static const char O_AUTO_STD0_1_STR[]="std0.1";
-static const char O_AUTO_STD0_5_STR[]="std0.5";
-static const char O_AUTO_STD1_STR[]="std1";
-static const char O_AUTO_STD2_STR[]="std2";
-static const char O_AUTO_STD3_STR[]="std3";
-
-enum { O_CENTER_MEDIAN, O_CENTER_MEAN, O_CENTER_MODE };
-static const char O_CENTER_MEAN_STR[]="mean";
-static const char O_CENTER_MODE_STR[]="mode";
-static const char O_CENTER_MEDIAN_STR[]="median";
-
-enum { O_FORMAT_GIF, O_FORMAT_PNG, O_FORMAT_PNG16, O_FORMAT_PGM, O_FORMAT_PGMASC, O_FORMAT_DISP };
-static const char O_FORMAT_GIF_STR[]="gif";
-static const char O_FORMAT_PNG_STR[]="png" ;
-static const char O_FORMAT_PNG16_STR[]="png16" ;
-static const char O_FORMAT_PGM_STR[]="pgm";
-static const char O_FORMAT_PGMASC_STR[]="pgmasc";
-static const char O_FORMAT_DISP_STR[]="disp";
-
-void
-if2img_usage (const char *program)
-{
- std::cout << "usage: " << fileBasename(program) << " ifname outfile [OPTIONS]\n";
- std::cout << "Convert IF file to an image file\n";
- std::cout << std::endl;
- std::cout << " ifname Name of input file\n";
- std::cout << " outfile Name of output file\n";
- std::cout << " --format Output format\n";
- std::cout << " pgm PGM (portable graymap) format (default)\n";
- std::cout << " pgmasc PGM (portable graymap) ASCII format\n";
-#ifdef HAVE_PNG
- std::cout << " png PNG (8-bit) format\n";
- std::cout << " png16 PNG (16-bit) format\n";
-#endif
-#if HAVE_G2
- std::cout << " gif GIF format\n";
-#endif
- std::cout << " disp Display on screen\n";
- std::cout << " --center Center of window\n";
- std::cout << " median Median is center of window (default)\n";
- std::cout << " mode Mode is center of window\n";
- std::cout << " mean Mean is center of window\n";
- std::cout << " --auto Set auto window\n";
- std::cout << " full Use full window (default)\n";
- std::cout << " std0.1 Use 0.1 standard deviation about center\n";
- std::cout << " std0.5 Use 0.5 standard deviation about center\n";
- std::cout << " std1 Use one standard deviation about center\n";
- std::cout << " std2 Use two standard deviations about center\n";
- std::cout << " std3 Use three standard deviations about center\n";
- std::cout << " --scale Scaling factor for output size\n";
- std::cout << " --min Set minimum intensity\n";
- std::cout << " --max Set maximum intensity\n";
- std::cout << " --stats Print image statistics\n";
- std::cout << " --labels Print image labels\n";
- std::cout << " --debug Set debug mode\n";
- std::cout << " --verbose Set verbose mode\n";
- std::cout << " --version Print version\n";
- std::cout << " --help Print this help message\n";
-}
-
-
-int
-if2img_main (int argc, char *const argv[])
-{
- ImageFile* pim = NULL;
- double densmin = HUGE_VAL, densmax = -HUGE_VAL;
- char *in_file, *out_file;
- int opt_verbose = 0;
- int opt_scale = 1;
- int opt_auto = O_AUTO_FULL;
- int opt_set_max = 0;
- int opt_set_min = 0;
- int opt_stats = 0;
- int opt_debug = 0;
- int opt_center = O_CENTER_MEDIAN;
- int opt_format = O_FORMAT_PGM;
- int opt_labels = 0;
-
- while (1)
- {
- int c = getopt_long (argc, argv, "", my_options, NULL);
- char *endptr = NULL;
- char *endstr;
-
- if (c == -1)
- break;
-
- switch (c)
- {
- case O_MIN:
- opt_set_min = 1;
- densmin = strtod(optarg, &endptr);
- endstr = optarg + strlen(optarg);
- if (endptr != endstr)
- {
- sys_error (ERR_SEVERE, "Error setting --min to %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_MAX:
- opt_set_max = 1;
- densmax = strtod(optarg, &endptr);
- endstr = optarg + strlen(optarg);
- if (endptr != endstr)
- {
- sys_error (ERR_SEVERE, "Error setting --max to %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_SCALE:
- opt_scale = strtol(optarg, &endptr, 10);
- endstr = optarg + strlen(optarg);
- if (endptr != endstr)
- {
- sys_error (ERR_SEVERE, "Error setting --scale to %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_AUTO:
- if (strcmp(optarg, O_AUTO_FULL_STR) == 0)
- opt_auto = O_AUTO_FULL;
- else if (strcmp(optarg, O_AUTO_STD1_STR) == 0)
- opt_auto = O_AUTO_STD1;
- else if (strcmp(optarg, O_AUTO_STD0_5_STR) == 0)
- opt_auto = O_AUTO_STD0_5;
- else if (strcmp(optarg, O_AUTO_STD0_1_STR) == 0)
- opt_auto = O_AUTO_STD0_1;
- else if (strcmp(optarg, O_AUTO_STD2_STR) == 0)
- opt_auto = O_AUTO_STD2;
- else if (strcmp(optarg, O_AUTO_STD3_STR) == 0)
- opt_auto = O_AUTO_STD3;
- else
- {
- sys_error (ERR_SEVERE, "Invalid auto mode %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_CENTER:
- if (strcmp(optarg, O_CENTER_MEDIAN_STR) == 0)
- opt_center = O_CENTER_MEDIAN;
- else if (strcmp(optarg, O_CENTER_MEAN_STR) == 0)
- opt_center = O_CENTER_MEAN;
- else if (strcmp(optarg, O_CENTER_MODE_STR) == 0)
- opt_center = O_CENTER_MODE;
- else
- {
- sys_error (ERR_SEVERE, "Invalid center mode %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_FORMAT:
- if (strcmp(optarg, O_FORMAT_PGM_STR) == 0)
- opt_format = O_FORMAT_PGM;
- else if (strcmp(optarg, O_FORMAT_PGMASC_STR) == 0)
- opt_format = O_FORMAT_PGMASC;
-#if HAVE_PNG
- else if (strcmp(optarg, O_FORMAT_PNG_STR) == 0)
- opt_format = O_FORMAT_PNG;
- else if (strcmp(optarg, O_FORMAT_PNG16_STR) == 0)
- opt_format = O_FORMAT_PNG16;
-#endif
-#if HAVE_GIF
- else if (strcmp(optarg, O_FORMAT_GIF_STR) == 0)
- opt_format = O_FORMAT_GIF;
-#endif
- else if (strcmp(optarg, O_FORMAT_DISP_STR) == 0)
- opt_format = O_FORMAT_DISP;
- else {
- sys_error (ERR_SEVERE, "Invalid format mode %s", optarg);
- if2img_usage(argv[0]);
- return (1);
- }
- break;
- case O_LABELS:
- opt_labels = 1;
- break;
- case O_VERBOSE:
- opt_verbose = 1;
- break;
- case O_DEBUG:
- opt_debug = 1;
- break;
- case O_STATS:
- opt_stats = 1;
- break;
- case O_VERSION:
-#ifdef VERSION
- std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
-#else
- std::cout << "Unknown version number\n";
-#endif
- return (0);
- case O_HELP:
- case '?':
- if2img_usage(argv[0]);
- return (0);
- default:
- if2img_usage(argv[0]);
- return (1);
- }
- }
-
-#if HAVE_SGP
- if (optind + 1 == argc)
- opt_format = O_FORMAT_DISP; // display image if no options
-#endif
-
- if ((opt_format == O_FORMAT_DISP && optind + 1 != argc)
- || (opt_format != O_FORMAT_DISP && optind + 2 != argc)) {
- if2img_usage(argv[0]);
- return (1);
- }
-
- in_file = argv[optind];
-
- if (opt_format != O_FORMAT_DISP)
- out_file = argv[optind+1];
- else out_file = NULL;
-
- pim = new ImageFile ();
- ImageFile& im = *pim;
- if (! im.fileRead(in_file)) {
- sys_error (ERR_FATAL, "File %s does not exist", in_file);
- return (1);
- }
-
- if (opt_labels)
- im.printLabels(std::cout);
-
- if (opt_stats || (! (opt_set_max && opt_set_min))) {
- double min, max, mean, mode, median, stddev;
- double window = 0;
- im.statistics(min, max, mean, mode, median, stddev);
-
- if (opt_auto == O_AUTO_FULL) {
- if (! opt_set_max)
- densmax = max;
- if (! opt_set_min)
- densmin = min;
- }
- if (opt_stats || opt_auto != O_AUTO_FULL) {
-
- if (opt_auto == O_AUTO_FULL)
- ;
- else if (opt_auto == O_AUTO_STD1)
- window = stddev;
- else if (opt_auto == O_AUTO_STD0_1)
- window = stddev * 0.1;
- else if (opt_auto == O_AUTO_STD0_5)
- window = stddev * 0.5;
- else if (opt_auto == O_AUTO_STD2)
- window = stddev * 2;
- else if (opt_auto == O_AUTO_STD3)
- window = stddev * 3;
- else {
- sys_error (ERR_SEVERE, "Internal Error: Invalid auto mode %d", opt_auto);
- return (1);
- }
- }
- if (opt_stats) {
- std::cout <<"nx: " << im.nx() << std::endl;
- std::cout <<"ny: " << im.ny() << std::endl;
- std::cout <<"min: " << min << std::endl;
- std::cout <<"max: " << max << std::endl;
- std::cout <<"mean: " << mean << std::endl;
- std::cout <<"mode: " << mode << std::endl;
- std::cout <<"stddev: " << stddev << std::endl;
- }
- if (opt_auto != O_AUTO_FULL) {
- double center;
-
- if (opt_center == O_CENTER_MEDIAN)
- center = median;
- else if (opt_center == O_CENTER_MODE)
- center = mode;
- else if (opt_center == O_CENTER_MEAN)
- center = mean;
- else {
- sys_error (ERR_SEVERE, "Internal Error: Invalid center mode %d", opt_center);
- return (1);
- }
- if (! opt_set_max)
- densmax = center + window;
- if (! opt_set_min)
- densmin = center - window;
- }
- }
-
- if (opt_stats) {
- std::cout << "min display: " << densmin << std::endl;
- std::cout << "max display: " << densmax << std::endl;
- }
-
- if (opt_format == O_FORMAT_PGM)
- im.writeImagePGM (out_file, opt_scale, opt_scale, densmin, densmax);
- else if (opt_format == O_FORMAT_PGMASC)
- im.writeImagePGMASCII (out_file, opt_scale, opt_scale, densmin, densmax);
-#if HAVE_PNG
- else if (opt_format == O_FORMAT_PNG)
- im.writeImagePNG (out_file, 8, opt_scale, opt_scale, densmin, densmax);
- else if (opt_format == O_FORMAT_PNG16)
- im.writeImagePNG (out_file, 16, opt_scale, opt_scale, densmin, densmax);
-#endif
-#if HAVE_GIF
- else if (opt_format == O_FORMAT_GIF)
- im.writeImageGIF (out_file, opt_scale, opt_scale, densmin, densmax);
-#endif
- else if (opt_format == O_FORMAT_DISP) {
-#if HAVE_SGP
- im.displayScaling (opt_scale, densmin, densmax);
- std::cout << "Press enter to continue\n";
- cio_kb_getc();
-#endif
- }
- else
- {
- sys_error (ERR_SEVERE, "Internal Error: Invalid format mode %d", opt_format);
- return (1);
- }
- return (0);
-}
-
-
-#ifndef NO_MAIN
-int
-main (int argc, char *const argv[])
-{
- int retval = 1;
-
- try {
- retval = if2img_main(argc, argv);
- } catch (exception e) {
- cerr << "Exception: " << e.what() << std::endl;
- } catch (...) {
- cerr << "Unknown exception\n";
- }
-
- return (retval);
-}
-#endif
--- /dev/null
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+** Name: ifexport.cpp
+** Purpose: Convert an image file to a viewable image
+** Programmer: Kevin Rosenberg
+** Date Started: April 2000
+**
+** This is part of the CTSim program
+** Copyright (C) 1983-2000 Kevin Rosenberg
+**
+** $Id: ifexport.cpp,v 1.1 2000/12/17 22:39:23 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
+** published by the Free Software Foundation.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+******************************************************************************/
+
+#include "ct.h"
+
+
+enum { O_SCALE, O_MIN, O_MAX, O_AUTO, O_CENTER, O_STATS, O_FORMAT, O_LABELS,
+ O_HELP, O_VERBOSE, O_VERSION, O_DEBUG };
+
+static struct option my_options[] =
+{
+ {"scale", 1, 0, O_SCALE},
+ {"min", 1, 0, O_MIN},
+ {"max", 1, 0, O_MAX},
+ {"auto", 1, 0, O_AUTO},
+ {"center", 1, 0, O_CENTER},
+ {"format", 1, 0, O_FORMAT},
+ {"labels", 0, 0, O_LABELS},
+ {"stats", 0, 0, O_STATS},
+ {"verbose", 0, 0, O_VERBOSE},
+ {"debug", 0, 0, O_DEBUG},
+ {"help", 0, 0, O_HELP},
+ {"version", 0, 0, O_VERSION},
+ {0, 0, 0, 0}
+};
+
+static const char* g_szIdStr = "$Id: ifexport.cpp,v 1.1 2000/12/17 22:39:23 kevin Exp $";
+
+enum { O_AUTO_FULL, O_AUTO_STD0_1, O_AUTO_STD0_5, O_AUTO_STD1, O_AUTO_STD2, O_AUTO_STD3 };
+static const char O_AUTO_FULL_STR[]="full";
+static const char O_AUTO_STD0_1_STR[]="std0.1";
+static const char O_AUTO_STD0_5_STR[]="std0.5";
+static const char O_AUTO_STD1_STR[]="std1";
+static const char O_AUTO_STD2_STR[]="std2";
+static const char O_AUTO_STD3_STR[]="std3";
+
+enum { O_CENTER_MEDIAN, O_CENTER_MEAN, O_CENTER_MODE };
+static const char O_CENTER_MEAN_STR[]="mean";
+static const char O_CENTER_MODE_STR[]="mode";
+static const char O_CENTER_MEDIAN_STR[]="median";
+
+enum { O_FORMAT_GIF, O_FORMAT_PNG, O_FORMAT_PNG16, O_FORMAT_PGM, O_FORMAT_PGMASC, O_FORMAT_DISP };
+static const char O_FORMAT_GIF_STR[]="gif";
+static const char O_FORMAT_PNG_STR[]="png" ;
+static const char O_FORMAT_PNG16_STR[]="png16" ;
+static const char O_FORMAT_PGM_STR[]="pgm";
+static const char O_FORMAT_PGMASC_STR[]="pgmasc";
+static const char O_FORMAT_DISP_STR[]="disp";
+
+void
+ifexport_usage (const char *program)
+{
+ std::cout << "usage: " << fileBasename(program) << " ifname outfile [OPTIONS]\n";
+ std::cout << "Convert IF file to an image file\n";
+ std::cout << std::endl;
+ std::cout << " ifname Name of input file\n";
+ std::cout << " outfile Name of output file\n";
+ std::cout << " --format Output format\n";
+ std::cout << " pgm PGM (portable graymap) format (default)\n";
+ std::cout << " pgmasc PGM (portable graymap) ASCII format\n";
+#ifdef HAVE_PNG
+ std::cout << " png PNG (8-bit) format\n";
+ std::cout << " png16 PNG (16-bit) format\n";
+#endif
+#if HAVE_G2
+ std::cout << " gif GIF format\n";
+#endif
+ std::cout << " disp Display on screen\n";
+ std::cout << " --center Center of window\n";
+ std::cout << " median Median is center of window (default)\n";
+ std::cout << " mode Mode is center of window\n";
+ std::cout << " mean Mean is center of window\n";
+ std::cout << " --auto Set auto window\n";
+ std::cout << " full Use full window (default)\n";
+ std::cout << " std0.1 Use 0.1 standard deviation about center\n";
+ std::cout << " std0.5 Use 0.5 standard deviation about center\n";
+ std::cout << " std1 Use one standard deviation about center\n";
+ std::cout << " std2 Use two standard deviations about center\n";
+ std::cout << " std3 Use three standard deviations about center\n";
+ std::cout << " --scale Scaling factor for output size\n";
+ std::cout << " --min Set minimum intensity\n";
+ std::cout << " --max Set maximum intensity\n";
+ std::cout << " --stats Print image statistics\n";
+ std::cout << " --labels Print image labels\n";
+ std::cout << " --debug Set debug mode\n";
+ std::cout << " --verbose Set verbose mode\n";
+ std::cout << " --version Print version\n";
+ std::cout << " --help Print this help message\n";
+}
+
+
+int
+ifexport_main (int argc, char *const argv[])
+{
+ ImageFile* pim = NULL;
+ double densmin = HUGE_VAL, densmax = -HUGE_VAL;
+ char *in_file, *out_file;
+ int opt_verbose = 0;
+ int opt_scale = 1;
+ int opt_auto = O_AUTO_FULL;
+ int opt_set_max = 0;
+ int opt_set_min = 0;
+ int opt_stats = 0;
+ int opt_debug = 0;
+ int opt_center = O_CENTER_MEDIAN;
+ int opt_format = O_FORMAT_PGM;
+ int opt_labels = 0;
+
+ while (1)
+ {
+ int c = getopt_long (argc, argv, "", my_options, NULL);
+ char *endptr = NULL;
+ char *endstr;
+
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case O_MIN:
+ opt_set_min = 1;
+ densmin = strtod(optarg, &endptr);
+ endstr = optarg + strlen(optarg);
+ if (endptr != endstr)
+ {
+ sys_error (ERR_SEVERE, "Error setting --min to %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_MAX:
+ opt_set_max = 1;
+ densmax = strtod(optarg, &endptr);
+ endstr = optarg + strlen(optarg);
+ if (endptr != endstr)
+ {
+ sys_error (ERR_SEVERE, "Error setting --max to %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_SCALE:
+ opt_scale = strtol(optarg, &endptr, 10);
+ endstr = optarg + strlen(optarg);
+ if (endptr != endstr)
+ {
+ sys_error (ERR_SEVERE, "Error setting --scale to %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_AUTO:
+ if (strcmp(optarg, O_AUTO_FULL_STR) == 0)
+ opt_auto = O_AUTO_FULL;
+ else if (strcmp(optarg, O_AUTO_STD1_STR) == 0)
+ opt_auto = O_AUTO_STD1;
+ else if (strcmp(optarg, O_AUTO_STD0_5_STR) == 0)
+ opt_auto = O_AUTO_STD0_5;
+ else if (strcmp(optarg, O_AUTO_STD0_1_STR) == 0)
+ opt_auto = O_AUTO_STD0_1;
+ else if (strcmp(optarg, O_AUTO_STD2_STR) == 0)
+ opt_auto = O_AUTO_STD2;
+ else if (strcmp(optarg, O_AUTO_STD3_STR) == 0)
+ opt_auto = O_AUTO_STD3;
+ else
+ {
+ sys_error (ERR_SEVERE, "Invalid auto mode %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_CENTER:
+ if (strcmp(optarg, O_CENTER_MEDIAN_STR) == 0)
+ opt_center = O_CENTER_MEDIAN;
+ else if (strcmp(optarg, O_CENTER_MEAN_STR) == 0)
+ opt_center = O_CENTER_MEAN;
+ else if (strcmp(optarg, O_CENTER_MODE_STR) == 0)
+ opt_center = O_CENTER_MODE;
+ else
+ {
+ sys_error (ERR_SEVERE, "Invalid center mode %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_FORMAT:
+ if (strcmp(optarg, O_FORMAT_PGM_STR) == 0)
+ opt_format = O_FORMAT_PGM;
+ else if (strcmp(optarg, O_FORMAT_PGMASC_STR) == 0)
+ opt_format = O_FORMAT_PGMASC;
+#if HAVE_PNG
+ else if (strcmp(optarg, O_FORMAT_PNG_STR) == 0)
+ opt_format = O_FORMAT_PNG;
+ else if (strcmp(optarg, O_FORMAT_PNG16_STR) == 0)
+ opt_format = O_FORMAT_PNG16;
+#endif
+#if HAVE_GIF
+ else if (strcmp(optarg, O_FORMAT_GIF_STR) == 0)
+ opt_format = O_FORMAT_GIF;
+#endif
+ else if (strcmp(optarg, O_FORMAT_DISP_STR) == 0)
+ opt_format = O_FORMAT_DISP;
+ else {
+ sys_error (ERR_SEVERE, "Invalid format mode %s", optarg);
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ break;
+ case O_LABELS:
+ opt_labels = 1;
+ break;
+ case O_VERBOSE:
+ opt_verbose = 1;
+ break;
+ case O_DEBUG:
+ opt_debug = 1;
+ break;
+ case O_STATS:
+ opt_stats = 1;
+ break;
+ case O_VERSION:
+#ifdef VERSION
+ std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
+#else
+ std::cout << "Unknown version number\n";
+#endif
+ return (0);
+ case O_HELP:
+ case '?':
+ ifexport_usage(argv[0]);
+ return (0);
+ default:
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+ }
+
+#if HAVE_SGP
+ if (optind + 1 == argc)
+ opt_format = O_FORMAT_DISP; // display image if no options
+#endif
+
+ if ((opt_format == O_FORMAT_DISP && optind + 1 != argc)
+ || (opt_format != O_FORMAT_DISP && optind + 2 != argc)) {
+ ifexport_usage(argv[0]);
+ return (1);
+ }
+
+ in_file = argv[optind];
+
+ if (opt_format != O_FORMAT_DISP)
+ out_file = argv[optind+1];
+ else out_file = NULL;
+
+ pim = new ImageFile ();
+ ImageFile& im = *pim;
+ if (! im.fileRead(in_file)) {
+ sys_error (ERR_FATAL, "File %s does not exist", in_file);
+ return (1);
+ }
+
+ if (opt_labels)
+ im.printLabels(std::cout);
+
+ if (opt_stats || (! (opt_set_max && opt_set_min))) {
+ double min, max, mean, mode, median, stddev;
+ double window = 0;
+ im.statistics(min, max, mean, mode, median, stddev);
+
+ if (opt_auto == O_AUTO_FULL) {
+ if (! opt_set_max)
+ densmax = max;
+ if (! opt_set_min)
+ densmin = min;
+ }
+ if (opt_stats || opt_auto != O_AUTO_FULL) {
+
+ if (opt_auto == O_AUTO_FULL)
+ ;
+ else if (opt_auto == O_AUTO_STD1)
+ window = stddev;
+ else if (opt_auto == O_AUTO_STD0_1)
+ window = stddev * 0.1;
+ else if (opt_auto == O_AUTO_STD0_5)
+ window = stddev * 0.5;
+ else if (opt_auto == O_AUTO_STD2)
+ window = stddev * 2;
+ else if (opt_auto == O_AUTO_STD3)
+ window = stddev * 3;
+ else {
+ sys_error (ERR_SEVERE, "Internal Error: Invalid auto mode %d", opt_auto);
+ return (1);
+ }
+ }
+ if (opt_stats) {
+ std::cout <<"nx: " << im.nx() << std::endl;
+ std::cout <<"ny: " << im.ny() << std::endl;
+ std::cout <<"min: " << min << std::endl;
+ std::cout <<"max: " << max << std::endl;
+ std::cout <<"mean: " << mean << std::endl;
+ std::cout <<"mode: " << mode << std::endl;
+ std::cout <<"stddev: " << stddev << std::endl;
+ }
+ if (opt_auto != O_AUTO_FULL) {
+ double center;
+
+ if (opt_center == O_CENTER_MEDIAN)
+ center = median;
+ else if (opt_center == O_CENTER_MODE)
+ center = mode;
+ else if (opt_center == O_CENTER_MEAN)
+ center = mean;
+ else {
+ sys_error (ERR_SEVERE, "Internal Error: Invalid center mode %d", opt_center);
+ return (1);
+ }
+ if (! opt_set_max)
+ densmax = center + window;
+ if (! opt_set_min)
+ densmin = center - window;
+ }
+ }
+
+ if (opt_stats) {
+ std::cout << "min display: " << densmin << std::endl;
+ std::cout << "max display: " << densmax << std::endl;
+ }
+
+ if (opt_format == O_FORMAT_PGM)
+ im.writeImagePGM (out_file, opt_scale, opt_scale, densmin, densmax);
+ else if (opt_format == O_FORMAT_PGMASC)
+ im.writeImagePGMASCII (out_file, opt_scale, opt_scale, densmin, densmax);
+#if HAVE_PNG
+ else if (opt_format == O_FORMAT_PNG)
+ im.writeImagePNG (out_file, 8, opt_scale, opt_scale, densmin, densmax);
+ else if (opt_format == O_FORMAT_PNG16)
+ im.writeImagePNG (out_file, 16, opt_scale, opt_scale, densmin, densmax);
+#endif
+#if HAVE_GIF
+ else if (opt_format == O_FORMAT_GIF)
+ im.writeImageGIF (out_file, opt_scale, opt_scale, densmin, densmax);
+#endif
+ else if (opt_format == O_FORMAT_DISP) {
+#if HAVE_SGP
+ im.displayScaling (opt_scale, densmin, densmax);
+ std::cout << "Press enter to continue\n";
+ cio_kb_getc();
+#endif
+ }
+ else
+ {
+ sys_error (ERR_SEVERE, "Internal Error: Invalid format mode %d", opt_format);
+ return (1);
+ }
+ return (0);
+}
+
+
+#ifndef NO_MAIN
+int
+main (int argc, char *const argv[])
+{
+ int retval = 1;
+
+ try {
+ retval = ifexport_main(argc, argv);
+ } catch (exception e) {
+ cerr << "Exception: " << e.what() << std::endl;
+ } catch (...) {
+ cerr << "Unknown exception\n";
+ }
+
+ return (retval);
+}
+#endif
${bin}phm2if sample-phm.if 256 256 --nsample 2 --phantom herman
if [ -f sample-phm.if ] ; then
- ${bin}if2img sample-phm.if sample-phm.png --format png
- ${bin}if2img sample-phm.if sample-phm16.png --format png16
+ ${bin}ifexport sample-phm.if sample-phm.png --format png
+ ${bin}ifexport sample-phm.if sample-phm16.png --format png16
fi
# Simulate CT data collection and generate raysum sinugram for display
${bin}pj2if sample-pj.pj sample-pj.if
fi
if [ -f sample-pj.if ]; then
- ${bin}if2img sample-pj.if sample-pj.png --format png
- ${bin}if2img sample-pj.if sample-pj16.png --format png16
+ ${bin}ifexport sample-pj.if sample-pj.png --format png
+ ${bin}ifexport sample-pj.if sample-pj16.png --format png16
fi
# Reconstruct raysums and generate image for display
${bin}pjrec sample-pj.pj sample-rec.if 256 256
if [ -f sample-rec.if ]; then
- ${bin}if2img sample-rec.if sample-rec.png --format png
- ${bin}if2img sample-rec.if sample-rec16.png --format png16
+ ${bin}ifexport sample-rec.if sample-rec.png --format png
+ ${bin}ifexport sample-rec.if sample-rec16.png --format png16
${bin}if-2 sample-phm.if sample-rec.if --comp
fi