X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=tools%2Fif1.cpp;h=cd97513edc1953fd1328acaf3cf2a38a4684aa5a;hp=9e4c1694f5a70746f853633402ab5ca14685911e;hb=e89023477e02d9332f87cab5a7975407625dbd60;hpb=5c6b29ab4885308cc3381af6e0a68f4804956d2e diff --git a/tools/if1.cpp b/tools/if1.cpp index 9e4c169..cd97513 100644 --- a/tools/if1.cpp +++ b/tools/if1.cpp @@ -7,9 +7,7 @@ ** Date Started: Aug 1984 ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: if1.cpp,v 1.3 2000/12/29 15:45:06 kevin Exp $ +** 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 @@ -46,9 +44,9 @@ static struct option my_options[] = {0, 0, 0, 0} }; -static const char* g_szIdStr = "$Id: if1.cpp,v 1.3 2000/12/29 15:45:06 kevin Exp $"; +static const char* g_szIdStr = "$Id$"; -void +void if1_usage (const char *program) { std::cout << "usage: " << fileBasename(program) << " infile outfile [OPTIONS]" << std::endl; @@ -59,12 +57,12 @@ if1_usage (const char *program) std::cout << " --exp Natural exponential of image" << std::endl; std::cout << " --sqr Square of image" << std::endl; std::cout << " --sqrt Square root of image" << std::endl; - std::cout << " --verbose Verbose modem" << std::endl; + std::cout << " --verbose Verbose mode" << std::endl; std::cout << " --version Print version" << std::endl; std::cout << " --help Print this help message" << std::endl; } -int +int if1_main (int argc, char *const argv[]) { char *in_file; @@ -75,49 +73,50 @@ if1_main (int argc, char *const argv[]) int opt_exp = 0; int opt_sqr = 0; int opt_sqrt = 0; - + UNUSED(opt_verbose); + while (1) { int c = getopt_long (argc, argv, "", my_options, NULL); - + if (c == -1) - break; - + break; + switch (c) - { - case O_INVERT: - opt_invert = 1; - break; - case O_LOG: - opt_log = 1; - break; - case O_SQR: - opt_sqr = 1; - break; - case O_SQRT: - opt_sqrt = 1; - break; - case O_EXP: - opt_exp = 1; - break; - case O_VERBOSE: - opt_verbose = 1; - break; + { + case O_INVERT: + opt_invert = 1; + break; + case O_LOG: + opt_log = 1; + break; + case O_SQR: + opt_sqr = 1; + break; + case O_SQRT: + opt_sqrt = 1; + break; + case O_EXP: + opt_exp = 1; + break; + case O_VERBOSE: + opt_verbose = 1; + break; case O_VERSION: #ifdef VERSION - std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl; + std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl; #else std::cout << "Unknown version number" << std::endl; #endif - return (0); - case O_HELP: - case '?': - if1_usage(argv[0]); - return (0); - default: - if1_usage(argv[0]); - return (1); - } + return (0); + case O_HELP: + case '?': + if1_usage(argv[0]); + return (0); + default: + if1_usage(argv[0]); + return (1); + } } if (optind + 2 != argc) @@ -125,7 +124,7 @@ if1_main (int argc, char *const argv[]) if1_usage(argv[0]); return (1); } - + in_file = argv[optind]; out_file = argv[optind + 1]; @@ -138,23 +137,23 @@ if1_main (int argc, char *const argv[]) int ny = im_in.ny(); ImageFile im_out (nx, ny); - if (opt_invert) { + if (opt_invert) { im_in.invertPixelValues (im_out); histString = "Invert transformation"; } - if (opt_log) { + if (opt_log) { im_in.log (im_out); histString = "Logrithmic transformation"; } - if (opt_exp) { + if (opt_exp) { im_in.exp (im_out); histString = "Exponential transformation"; } - if (opt_sqr) { + if (opt_sqr) { im_in.square (im_out); histString = "Square transformation"; } - if (opt_sqrt) { + if (opt_sqrt) { im_in.sqrt (im_out); histString = "Square root transformation"; } @@ -168,7 +167,7 @@ if1_main (int argc, char *const argv[]) } #ifndef NO_MAIN -int +int main (int argc, char *const argv[]) { int retval = 1;