** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if2img.cpp,v 1.1 2000/07/13 07:01:35 kevin Exp $
+** $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
{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_STD2_STR[]="std2";
static const char O_AUTO_STD3_STR[]="std3";
-enum { O_CENTER_MEAN, O_CENTER_MODE };
+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";
void
if2img_usage (const char *program)
{
- cout << "usage: " << fileBasename(program) << " ifname outfile [OPTIONS]" << endl;
- cout << "Convert IF file to an image file" << endl;
- cout << endl;
- cout << " ifname Name of input file" << endl;
- cout << " outfile Name of output file" << endl;
- cout << " --format Output format" << endl;
- cout << " pgm PGM (portable graymap) format (default)" << endl;
- cout << " pgmasc PGM (portable graymap) ASCII format" << endl;
+ 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
- cout << " png PNG (8-bit) format" << endl;
- cout << " png16 PNG (16-bit) format" << endl;
+ std::cout << " png PNG (8-bit) format\n";
+ std::cout << " png16 PNG (16-bit) format\n";
#endif
#if HAVE_G2
- cout << " gif GIF format" << endl;
+ std::cout << " gif GIF format\n";
#endif
- cout << " disp Display on screen" << endl;
- cout << " --center Center of window" << endl;
- cout << " mode Mode is center of window (default)" << endl;
- cout << " mean Mean is center of window" << endl;
- cout << " --auto Set auto window" << endl;
- cout << " full Use full window (default)" << endl;
- cout << " std0.1 Use 0.1 standard deviation about center" << endl;
- cout << " std0.5 Use 0.5 standard deviation about center" << endl;
- cout << " std1 Use one standard deviation about center" << endl;
- cout << " std2 Use two standard deviations about center" << endl;
- cout << " std3 Use three standard deviations about center" << endl;
- cout << " --scale Scaling factor for output size" << endl;
- cout << " --min Set minimum intensity" << endl;
- cout << " --max Set maximum intensity" << endl;
- cout << " --stats Print image statistics" << endl;
- cout << " --labels Print image labels" << endl;
- cout << " --debug Set debug mode" << endl;
- cout << " --verbose Set verbose mode" << endl;
- cout << " --version Print version" << endl;
- cout << " --help Print this help message" << endl;
+ 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 opt_set_min = 0;
int opt_stats = 0;
int opt_debug = 0;
- int opt_center = O_CENTER_MODE;
+ int opt_center = O_CENTER_MEDIAN;
int opt_format = O_FORMAT_PGM;
int opt_labels = 0;
}
break;
case O_CENTER:
- if (strcmp(optarg, O_CENTER_MEAN_STR) == 0)
+ 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;
break;
case O_VERSION:
#ifdef VERSION
- cout << "Version " << VERSION;
+ std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
#else
- cout << "Unknown version number" << endl;
+ std::cout << "Unknown version number\n";
#endif
return (0);
case O_HELP:
}
}
+#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);
- }
+ || (opt_format != O_FORMAT_DISP && optind + 2 != argc)) {
+ if2img_usage(argv[0]);
+ return (1);
+ }
in_file = argv[optind];
}
if (opt_labels)
- im.printLabels(cout);
+ im.printLabels(std::cout);
if (opt_stats || (! (opt_set_max && opt_set_min))) {
double min, max, mean, mode, median, stddev;
}
}
if (opt_stats) {
- cout <<"nx: " << im.nx() << endl;
- cout <<"ny: " << im.ny() << endl;
- cout <<"min: " << min << endl;
- cout <<"max: " << max << endl;
- cout <<"mean: " << mean << endl;
- cout <<"mode: " << mode << endl;
- cout <<"stddev: " << stddev << endl;
+ 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_MODE)
+ 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;
}
if (opt_stats) {
- cout << "min display: " << densmin << endl;
- cout << "max display: " << densmax << endl;
+ std::cout << "min display: " << densmin << std::endl;
+ std::cout << "max display: " << densmax << std::endl;
}
if (opt_format == O_FORMAT_PGM)
else if (opt_format == O_FORMAT_DISP) {
#if HAVE_SGP
im.displayScaling (opt_scale, densmin, densmax);
- cout << "Press enter to continue\n";
+ std::cout << "Press enter to continue\n";
cio_kb_getc();
- sgp2_close(sgp2_get_active_win());
#endif
}
else
try {
retval = if2img_main(argc, argv);
} catch (exception e) {
- cerr << "Exception: " << e.what() << endl;
+ cerr << "Exception: " << e.what() << std::endl;
} catch (...) {
- cerr << "Unknown exception" << endl;
+ cerr << "Unknown exception\n";
}
return (retval);