1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: sdf-1.c,v 1.2 2000/05/03 08:49:50 kevin Exp $
7 ** Revision 1.2 2000/05/03 08:49:50 kevin
10 ** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
11 ** Initial CVS import for first public release
15 ** This program is free software; you can redistribute it and/or modify
16 ** it under the terms of the GNU General Public License (version 2) as
17 ** published by the Free Software Foundation.
19 ** This program is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ** GNU General Public License for more details.
24 ** You should have received a copy of the GNU General Public License
25 ** along with this program; if not, write to the Free Software
26 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 ******************************************************************************/
29 * sdf-1.c Filter a single SDF file
41 static struct option my_options[] =
43 {"invert", 0, 0, O_INVERT},
44 {"verbose", 0, 0, O_VERBOSE},
47 {"help", 0, 0, O_HELP},
48 {"version", 0, 0, O_VERSION},
53 usage (const char *program)
55 fprintf(stdout, "usage: %s infile outfile [OPTIONS]\n", kbasename(program));
56 fprintf(stdout, "Generate a SDF2D file from a SDF2D file\n");
57 fprintf(stdout, "\n");
58 fprintf(stdout, " --invert Invert image\n");
59 fprintf(stdout, " --log Natural logrithm of image\n");
60 fprintf(stdout, " --exp Natural exponential of image\n");
61 fprintf(stdout, " --verbose Verbose modem\n");
62 fprintf(stdout, " --version Print version\n");
63 fprintf(stdout, " --help Print this help message\n");
68 main (int argc, char *const argv[])
81 int c = getopt_long (argc, argv, "", my_options, NULL);
102 fprintf(stdout, "Version %s\n", VERSION);
104 fprintf(stderr, "Unknown version number");
117 if (optind + 2 != argc)
123 in_file = argv[optind];
124 out_file = argv[optind + 1];
127 if (opt_invert || opt_log || opt_exp) {
130 im_in = image_load (in_file);
131 im_out = image_create (out_file, im_in->nx, im_in->ny);
134 for (ix = 0; ix < im_in->nx; ix++)
135 for (iy = 0; iy < im_in->ny; iy++)
136 im_out->v[ix][iy] = - im_in->v[ix][iy];
139 for (ix = 0; ix < im_in->nx; ix++)
140 for (iy = 0; iy < im_in->ny; iy++)
141 im_out->v[ix][iy] = log (im_in->v[ix][iy]);
144 for (ix = 0; ix < im_in->nx; ix++)
145 for (iy = 0; iy < im_in->ny; iy++)
146 im_out->v[ix][iy] = exp (im_in->v[ix][iy]);