1 /*****************************************************************************
5 ** Purpose: Master header file for CTSim
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: Aug 1984
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: ct.h,v 1.17 2000/06/19 15:48:23 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
33 #define HAVE_STRING_H 1
35 #define snprintf _snprintf
36 #define vsnprintf _vsnprintf
37 #define strcasecmp stricmp
38 #define strncasecmp strnicmp
72 #ifdef HAVE_SYS_TYPES_H
73 #include <sys/types.h>
75 #ifdef HAVE_SYS_STAT_H
84 #ifdef HAVE_SYS_FCNTL_H
85 #include <sys/fcntl.h>
90 #if defined(HAVE_GETOPT_H) || defined(HAVE_GETOPT_LONG)
99 #ifdef HAVE_SYS_PARAM_H
100 #include <sys/param.h> /* for htonl on FreeBSD */
102 #ifdef HAVE_NETINET_IN_H
103 #include <netinet/in.h> /* for htonl on Linux/Solaris */
105 #ifdef HAVE_INTTYPES_H
106 #include <inttypes.h> /* for htonl on Solaris */
109 #include <stdint.h> /* Standard ints on Linux */
114 #include "mpiworld.h"
119 #include "keyboard.h"
121 #include "byteorder.h"
138 #include "imagefile.h"
140 #include "projections.h"
143 //----------------------------------------------------------------------//
145 //----------------------------------------------------------------------//
148 static const char O_FILTER_ABS_BANDLIMIT_STR[]= "abs_bandlimit";
149 static const char O_FILTER_ABS_SINC_STR[]= "abs_sinc";
150 static const char O_FILTER_ABS_COS_STR[]= "abs_cos";
151 static const char O_FILTER_ABS_HAMMING_STR[]= "abs_hamming";
152 static const char O_FILTER_SHEPP_STR[]= "shepp";
153 static const char O_FILTER_BANDLIMIT_STR[]= "bandlimit";
154 static const char O_FILTER_SINC_STR[]= "sinc";
155 static const char O_FILTER_COS_STR[]= "cos";
156 static const char O_FILTER_HAMMING_STR[]= "hamming";
157 static const char O_FILTER_TRIANGLE_STR[]= "triangle";
165 FILTER_ABS_BANDLIMIT, // filter times |x|
167 FILTER_ABS_G_HAMMING,
174 static const char D_FREQ_STR[]= "freq";
175 static const char D_SPATIAL_STR[]= "spatial";
183 /* interpolation methods */
184 static const char O_INTERP_NEAREST_STR[]= "nearest";
185 static const char O_INTERP_LINEAR_STR[]= "linear";
186 static const char O_INTERP_BSPLINE_STR[]= "bspline";
188 #undef HAVE_BSPLINE_INTERP
189 typedef enum { // Interpolation methods
190 I_NEAREST = 1, // Nearest neighbor
191 #if HAVE_BSPLINE_INTERP
193 I_1BSPLINE, // 1st order B-Spline
197 I_LINEAR // Linear interpolation
202 static const char O_TRACE_NONE_STR[]= "none";
203 static const char O_TRACE_TEXT_STR[]= "text";
204 static const char O_TRACE_PHM_STR[]= "phm";
205 static const char O_TRACE_RAYS_STR[]= "rays";
206 static const char O_TRACE_PLOT_STR[]= "plot";
207 static const char O_TRACE_CLIPPING_STR[]= "clipping";
210 TRACE_NONE, /* No tracing */
211 TRACE_TEXT, /* Minimal status */
212 TRACE_PHM, /* Show phantom */
213 TRACE_RAYS, /* Show all rays */
214 TRACE_PLOT, /* Plot raysums */
215 TRACE_CLIPPING /* Plot clipping */
218 // Standard phantomsa
219 static const char O_PHM_HERMAN_STR[]= "herman";
220 static const char O_PHM_ROWLAND_STR[]= "rowland";
221 static const char O_PHM_BROWLAND_STR[]= "browland";
222 static const char O_PHM_UNITPULSE_STR[]= "unitpulse";
224 O_PHM_HERMAN, /* Herman head phantom */
225 O_PHM_ROWLAND, /* Rowland head phantom */
226 O_PHM_BROWLAND, /* Bordered Rowland head phantom */
227 O_PHM_UNITPULSE /* Unit pulse phantom */
231 static const char O_BPROJ_TRIG_STR[]= "trig";
232 static const char O_BPROJ_TABLE_STR[]= "table";
233 static const char O_BPROJ_DIFF_STR[]= "diff";
234 static const char O_BPROJ_DIFF2_STR[]= "diff2";
235 static const char O_BPROJ_IDIFF2_STR[]= "idiff2";
245 // Convolution symmetries
247 FUNC_EVEN = 1, // function types, f[-n] = f[n]
248 FUNC_ODD, // f[-n] = -f[n]
249 FUNC_BOTH // function has both odd & even components
254 #include "backprojectors.h"
257 /*************************************************************************
258 * FUNCTION DECLARATIONS
259 ************************************************************************/
262 double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
265 bool phm_add_pelem_kb (Phantom& phm);
266 const Phantom& phm_select (Phantom& phm);
267 int interpolation_select (void);
268 int filter_select (double *filter_param);
271 double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
272 double filter_spatial_response_calc (int filt_type, double x, double bw, double param, int n);
273 double filter_spatial_response_analytic (int filt_type, double x, double bw, double param);
274 double filter_frequency_response (int filt_type, double u, double bw, double param);
275 double sinc (double x, double mult);
276 double integral_abscos(double u, double w);
279 int opt_set_trace(const char *optarg);
280 const char *name_of_phantom(const int phmid);
281 int opt_set_phantom(const char *optarg);
282 InterpolationType opt_set_interpolation(const char *optarg);
283 const char *name_of_interpolation(int interp_type);
284 FilterType opt_set_filter(const char *optarg);
285 const char *name_of_filter(const int filter);
286 DomainType opt_set_filter_domain(const char *optarg);
287 const char *name_of_filter_domain(const DomainType domain);
288 BackprojType opt_set_backproj(const char *optarg);
289 const char *name_of_backproj(const BackprojType backproj);
291 // From phm2image.cpp
292 void phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
295 void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
296 int image_display (const ImageFile& im);
297 int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax);
300 ImageFile& proj_reconst (ImageFile& im, Projections& rs, const FilterType filt_type, double filt_param, InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace);