+0.5.2-b3 - 4/30/200
+ More code cleanup with reorganizing libraries
+
0.5.2-b2 - 4/30/200
Continued code cleanup
Number of Samples<br>per pixel: <input type="text" name="Phantom_NSample" size="2" value="1"><br>
<p>
Display Window:<br>
-Minium: <input type="text" name="Disp_Min" size=5 value="auto"><br>
+Minimum: <input type="text" name="Disp_Min" size=5 value="auto"><br>
Maximum: <input type="text" name="Disp_Max" size=5 value="auto"><br>
<p>
MPI Supercomputing:<br>
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ir.h,v 1.5 2000/05/02 20:00:25 kevin Exp $
+** $Id: ir.h,v 1.6 2000/05/03 08:49:49 kevin Exp $
** $Log: ir.h,v $
+** Revision 1.6 2000/05/03 08:49:49 kevin
+** Code cleanup
+**
** Revision 1.5 2000/05/02 20:00:25 kevin
** *** empty log message ***
**
IMAGE_VAL v; /* values of voxels in matrix form */
SDF_2D *dfp_2d; /* Pointer to disk image file */
int nx, ny; /* size of voxel matrix */
- double xmin, xmax, ymin, ymax; /* extent of voxel matrix in pic coord */
+ double xmin, xmax, ymin, ymax; /* extent of voxel matrix in phm coord */
char remark[LENREMARK]; /* description of voxel data */
float calctime; /* time to calculate voxels in seconds */
};
double xmin, xmax, ymin, ymax; /* object limits */
double radius; /* " */
struct { /* transform matrices */
- GRFMTX_2D p_to_o; /* map from pic to standard obj coords */
- GRFMTX_2D o_to_p; /* map from std object coords to pic coords */
+ GRFMTX_2D p_to_o; /* map from phm to standard obj coords */
+ GRFMTX_2D o_to_p; /* map from std object coords to phm coords */
} xform;
- struct object_st *next; /* pointer to next object in picture */
+ struct object_st *next; /* pointer to next object in PHANTOM */
};
typedef struct object_st OBJECT;
-struct pic_st { /* Picture structure */
+struct phm_st { /* PHANTOM structure */
OBJECT *objlist; /* object list */
int type;
- int numobj; /* number of objects in picture */
+ int numobj; /* number of objects in PHANTOM */
double xmin, xmax, ymin, ymax; /* extent of objects in object coordinates */
double radius; /* " " */
};
typedef struct image_st IMAGE;
-typedef struct pic_st PICTURE;
+typedef struct phm_st PHANTOM;
-#define P_OBJECTS 0 /* Picture made of objects */
-#define P_UNIT_PULSE 1 /* Special picture, not made of objects */
+#define P_OBJECTS 0 /* PHANTOM made of objects */
+#define P_UNIT_PULSE 1 /* Special PHANTOM, not made of objects */
#define P_FILTER 9 /* defined only by a type */
/*----------------------------------------------------------------------*/
struct detarray_st {
DETECT_TYPE *detval; /* Pointer to array of values recorded by detector */
- int ndet; /* Number of detectors in array */
+ int ndet; /* Number of detectors in array */
double view_angle; /* View angle in radians */
};
+#define DETECTOR_PARALLEL 1
+#define DETECTOR_EQUIANGLE 2
+#define DETECTOR_EQUILINEAR 3
+
struct detect_st {
+ int geometry; /* Geometry of detectory */
int ndet; /* Number of detectors in array */
int nview; /* Number of rotated views */
int nsample; /* Number of rays per detector */
double det_inc; /* Increment between centers of detectors */
double rot_inc; /* Increment in rotation angle between views */
double radius; /* Radius of rotation. Distance from */
- /* center of pic to center of det */
- double piclen; /* Maximum Length of picture or area of interest */
+ /* center of phm to center of det */
+ double phmlen; /* Maximum Length of PHANTOM or area of interest */
struct {
double xd1,yd1,xd2,yd2; /* Coordinates of detector endpoints */
double xs1,ys1,xs2,ys2; /* Coordinates of source endpoints */
double rot_start; /* starting view rotation */
double rot_inc; /* angle between rotations */
double det_start; /* distance of beginning detector to center */
- /* of picture */
+ /* of PHANTOM */
double det_inc; /* increment between detectors */
- double piclen; /* Length of picture edge (pic is square) */
+ double phmlen; /* Length of PHANTOM edge (phm is square) */
};
typedef struct detarray_st DETARRAY;
/* Defines coords for inside_obj() */
#define OBJ_COORD -1 /* Normalized Object Coordinates */
-#define PIC_COORD -2 /* User's Picture Coordinates */
+#define PHM_COORD -2 /* User's PHANTOM Coordinates */
/* Codes for Filter types */
#define I_2BSPLINE 4
#define I_3BSPLINE 5
-/* Constants for sizing picture */
+/* Constants for sizing PHANTOM */
-#define PERCENT_PIC_SIZE_INCR 0.0 /* Fractional increase in picture */
+#define PERCENT_PHM_SIZE_INCR 0.0 /* Fractional increase in PHANTOM */
/* limits compared to object size */
#define N_EXTRA_DETECTORS 4 /* Number of extra detectors */
/* widths when calculating detlen */
#define O_TRACE_NONE_STR "none"
#define O_TRACE_TEXT_STR "text"
-#define O_TRACE_PIC_STR "pic"
+#define O_TRACE_PHM_STR "phm"
#define O_TRACE_RAYS_STR "rays"
#define O_TRACE_PLOT_STR "plot"
#define O_TRACE_CLIPPING_STR "clipping"
#define TRACE_NONE 0 /* No tracing */
#define TRACE_TEXT 1 /* Minimal status */
-#define TRACE_PIC 2 /* Show picture */
+#define TRACE_PHM 2 /* Show PHANTOM */
#define TRACE_RAYS 3 /* Show all rays */
#define TRACE_PLOT 4 /* Plot raysums */
#define TRACE_CLIPPING 5 /* Plot clipping */
-#define O_PIC_HERMAN 1 /* Herman head phantom */
-#define O_PIC_ROWLAND 2 /* Rowland head phantom */
-#define O_PIC_BROWLAND 3 /* Bordered Rowland head phantom */
-#define O_PIC_UNITPULSE 4 /* Unit pulse phantom */
+#define O_PHM_HERMAN 1 /* Herman head phantom */
+#define O_PHM_ROWLAND 2 /* Rowland head phantom */
+#define O_PHM_BROWLAND 3 /* Bordered Rowland head phantom */
+#define O_PHM_UNITPULSE 4 /* Unit pulse phantom */
-#define O_PIC_HERMAN_STR "herman"
-#define O_PIC_ROWLAND_STR "rowland"
-#define O_PIC_BROWLAND_STR "browland"
-#define O_PIC_UNITPULSE_STR "unitpulse"
+#define O_PHM_HERMAN_STR "herman"
+#define O_PHM_ROWLAND_STR "rowland"
+#define O_PHM_BROWLAND_STR "browland"
+#define O_PHM_UNITPULSE_STR "unitpulse"
#define O_INTERP_NEAREST_STR "nearest"
#define O_INTERP_LINEAR_STR "linear"
void xlat2d(double x[], double y[], int pts, double xoffset, double yoffset);
void scale2d(double x[], double y[], int pts, double xfact, double yfact);
int circle_pts(double theta);
-/* filt.c */
-double d_filtfunc(int filt_type, double x, double bw, double param, int n);
-double filter_freq(int filt_type, double u, double bw, double param);
-double a_filtfunc(int filt_type, double x, double bw, double param);
+/* dialogs.c */
+int add_objs_kb(PHANTOM *phm);
+PHANTOM *phm_select(void);
+int interpolation_select(void);
+int filter_select(double *filter_param);
+/* filter.c */
+double *filter_generate(int filt_type, double bw, double xmin, double xmax, int n, double param, int domain, int numint);
+double filter_spatial_response_calc(int filt_type, double x, double bw, double param, int n);
+double filter_spatial_response_analytic(int filt_type, double x, double bw, double param);
+double filter_frequency_response(int filt_type, double u, double bw, double param);
double sinc(double x, double mult);
double abscos_int(double u, double w);
-double *filter_generate(int filt_type, double bw, double xmin, double xmax, int n, double param, int domain, int numint);
-void image_filter_init(IMAGE *im, int domain, double bw, int filt_type, double filt_param, int opt_trace);
-/* im_draw.c */
-void image_show(IMAGE *im, int nxcell, int nycell, double densmin, double densmax, bool disp_scale);
-int image_paint(int dev, IMAGE *im, int xmin, int ymin, int nxcell, int nycell, double densmin, double densmax, bool disp_scale);
-int gs_image(GREYSCALE *gs, IMAGE *im, double densmin, double densmax, bool disp_scale);
-void paint_cscale(GREYSCALE *gs, int nx, int ny);
-GREYSCALE *gs_init(int dev, int xmin, int ymin, int nxcell, int nycell);
-void gs_pixel(GREYSCALE *gs, int x, int y, int gs_level);
-void gs_set_pos(GREYSCALE *gs, int x, int y);
-void gs_set_at_addr(GREYSCALE *gs, int gs_level);
-void gs_set_color_scale(void);
/* image.c */
IMAGE *image_create(const char *fname, const int nx, const int ny);
int image_clear(IMAGE *im);
int image_save(IMAGE *im);
IMAGE *image_load(const char *fname);
-/* ir_vars.c */
+void image_filter_response(IMAGE *im, int domain, double bw, int filt_type, double filt_param, int opt_trace);
/* options.c */
int opt_set_trace(const char *optarg, const char *program);
-const char *name_of_picture(const int picnum);
-int opt_set_picture(const char *optarg, const char *program);
+const char *name_of_phantom(const int phmid);
+int opt_set_phantom(const char *optarg, const char *program);
int opt_set_interpolation(const char *optarg, const char *program);
const char *name_of_interpolation(int interp_type);
int opt_set_filter(const char *optarg, const char *program);
int opt_set_backproj(const char *optarg, const char *program);
const char *name_of_backproj(const int backproj);
/* phm.c */
-PICTURE *select_pic(void);
-PICTURE *create_pic_from_file(const char *fname);
-PICTURE *create_pic(const int picnum);
-PICTURE *init_pic(void);
-int add_objs_kb(PICTURE *pic);
-int add_objs_file(PICTURE *pic, const char *fname);
-void addobject(PICTURE *pic, const int type, const double cx, const double cy,
+PHANTOM *phm_create(const int phmid);
+PHANTOM *phm_create_from_file(const char *fname);
+PHANTOM *phm_init(void);
+int add_objs_kb(PHANTOM *phm);
+int add_objs_file(PHANTOM *phm, const char *fname);
+void addobject(PHANTOM *phm, const int type, const double cx, const double cy,
const double u, const double v, const double rot, const double atten);
int makeobjpts(OBJECT *obj);
void makeobjxform(OBJECT *obj);
const double r, const double start, const double stop);
void calc_ellipse(double x[], double y[], const int pts, const double u, const double v);
OBJECT *alloc_obj(void);
-void prt_pic(PICTURE *pic);
-void show_pic(const PICTURE *pic);
-void draw_pic(const PICTURE *pic);
+void phm_print(PHANTOM *phm);
+#if HAVE_INTERACTIVE_GRAPHICS
+void phm_show(const PHANTOM *phm);
+void phm_draw(const PHANTOM *phm);
+#endif
/* phm2image.c */
-void pic_to_image(const PICTURE *pic, IMAGE *im, const int col_start, const int col_count,
+void phm_to_image(const PHANTOM *phm, IMAGE *im, const int col_start, const int col_count,
const int nsample, const int trace);
int inside_obj(const OBJECT *obj, double x, double y, const int coord_type);
+/* phmstd.c */
+void herm_head(PHANTOM *phm);
+void row_head(PHANTOM *phm);
+void row_bord_head(PHANTOM *phm);
/* ray.c */
-DETECTOR *detect_create(const PICTURE *pic, int ndet, int nview, int nsample, const double rot_anglen);
+DETECTOR *detect_create(const PHANTOM *phm, int ndet, int nview, int nsample, const double rot_anglen);
void detect_free(DETECTOR *det);
-double calc_rsum(const PICTURE *pic, const double x1, const double y1, const double x2, const double y2);
+double calc_rsum(const PHANTOM *phm, const double x1, const double y1, const double x2, const double y2);
double calc_objsum(const OBJECT *obj, const double x1, const double y1, const double x2, const double y2);
int clipobj(const OBJECT *obj, double *x1, double *y1, double *x2, double *y2);
/* raycollect.c */
-int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PICTURE *pic, const int start_view,
+int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PHANTOM *phm, const int start_view,
const int trace, const int unit_pulse);
-void rayview(const PICTURE *pic, DETARRAY *darray, const DETECTOR *det,
+void rayview(const PHANTOM *phm, DETARRAY *darray, const DETECTOR *det,
const double xd1, const double yd1, const double xd2, const double yd2,
const double xs1, const double ys1, const double xs2, const double ys2, const int unit_pulse);
void rs_trace_showprm (const char *label, const char *fmt, int row, int color, ...);
int detarray_read(RAYSUM *rs, DETARRAY *darray, const int view_num);
int detarray_write(RAYSUM *rs, const DETARRAY *darray, const int view_num);
int raysum_print(const RAYSUM *rs);
-/* phmstd.c */
-void herm_head(PICTURE *pic);
-void row_head(PICTURE *pic);
-void row_bord_head(PICTURE *pic);
+
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.c,v 1.6 2000/05/02 15:31:47 kevin Exp $
+** $Id: ctrec.c,v 1.7 2000/05/03 08:49:50 kevin Exp $
** $Log: ctrec.c,v $
+** Revision 1.7 2000/05/03 08:49:50 kevin
+** Code cleanup
+**
** Revision 1.6 2000/05/02 15:31:47 kevin
** code cleaning
**
fprintf(stdout," --trace Set tracing to level\n");
fprintf(stdout," none No tracing (default)\n");
fprintf(stdout," status Status tracing\n");
- fprintf(stdout," pic Trace picture\n");
+ fprintf(stdout," phm Trace phantom\n");
fprintf(stdout," rays Trace allrays\n");
fprintf(stdout," plot Trace plotting\n");
fprintf(stdout," clipping Trace clipping\n");
int mpi_argc = argc;
char **mpi_argv = (char **) argv;
int mpi_nview, mpi_ndet;
- double mpi_detinc, mpi_rotinc, mpi_piclen;
+ double mpi_detinc, mpi_rotinc, mpi_phmlen;
double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
int ix;
mpi_ndet = rs_global->ndet;
mpi_nview = rs_global->nview;
mpi_detinc = rs_global->det_inc;
- mpi_piclen = rs_global->piclen;
+ mpi_phmlen = rs_global->phmlen;
mpi_rotinc = rs_global->rot_inc;
}
MPI_Bcast(&mpi_ndet, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&mpi_nview, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&mpi_detinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_piclen, 1, MPI_DOUBLE, 0, mpi_ct.comm);
+ MPI_Bcast(&mpi_phmlen, 1, MPI_DOUBLE, 0, mpi_ct.comm);
MPI_Bcast(&mpi_rotinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
MPI_Bcast(&nx, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&ny, 1, MPI_INT, 0, mpi_ct.comm);
rs_local->ndet = mpi_ndet;
rs_local->nview = mpi_nview;
rs_local->det_inc = mpi_detinc;
- rs_local->piclen = mpi_piclen;
+ rs_local->phmlen = mpi_phmlen;
rs_local->rot_inc = mpi_rotinc;
if (opt_verbose)
printf ("Number of detectors: %d\n", rs->ndet);
printf (" Number of views: %d\n", rs->nview);
printf (" Remark: %s\n", rs->remark);
- printf (" Piclen: %f\n", rs->piclen);
+ printf (" phmlen: %f\n", rs->phmlen);
printf (" det_start: %f\n", rs->det_start);
printf (" det_inc: %f\n", rs->det_inc);
printf (" rot_start: %f\n", rs->rot_start);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2rs.c,v 1.6 2000/04/30 18:23:53 kevin Exp $
+** $Id: phm2rs.c,v 1.7 2000/05/03 08:49:50 kevin Exp $
** $Log: phm2rs.c,v $
+** Revision 1.7 2000/05/03 08:49:50 kevin
+** Code cleanup
+**
** Revision 1.6 2000/04/30 18:23:53 kevin
** Code cleaning
**
#define O_TRACE 5
#define O_VERBOSE 6
#define O_HELP 7
-#define O_PICFILE 8
+#define O_PHMFILE 8
#define O_DEBUG 10
#define O_VERSION 11
static struct option my_options[] =
{
{"phantom", 1, 0, O_PHANTOM},
- {"picfile", 1, 0, O_PICFILE},
+ {"phmfile", 1, 0, O_PHMFILE},
{"desc", 1, 0, O_DESC},
{"nray", 1, 0, O_NRAY},
{"rotangle", 1, 0, O_ROTANGLE},
if (mpi_ct.my_rank == 0)
{
#endif
- fprintf(stdout,"usage: %s outfile ndet nview [--phantom phantom-name] [--picfile filename] [OPTIONS]\n", kbasename(program));
+ fprintf(stdout,"usage: %s outfile ndet nview [--phantom phantom-name] [--phmfile filename] [OPTIONS]\n", kbasename(program));
fprintf(stdout,"Calculate raysums (projections) through phantom object, either\n");
- fprintf(stdout,"a predefined --phantom or a --picfile\n");
+ fprintf(stdout,"a predefined --phantom or a --phmfile\n");
fprintf(stdout,"\n");
fprintf(stdout," outfile Name of output file for raysums\n");
fprintf(stdout," ndet Number of detectors\n");
fprintf(stdout," rowland Rowland head phantom\n");
fprintf(stdout," browland Bordered Rowland head phantom\n");
fprintf(stdout," unitpulse Unit pulse phantom\n");
- fprintf(stdout," --picfile Get Phantom from picture file\n");
+ fprintf(stdout," --phmfile Get Phantom from phantom file\n");
fprintf(stdout," --desc Description of raysum\n");
fprintf(stdout," --nray Number of rays per detector (default = 1)\n");
fprintf(stdout," --rotangle Degrees to rotate view through, multiple of PI (default = 1)\n");
fprintf(stdout," --trace Trace level to use\n");
fprintf(stdout," none No tracing (default)\n");
fprintf(stdout," text Trace text level\n");
- fprintf(stdout," pic Trace picture\n");
+ fprintf(stdout," phm Trace PHANTOM\n");
fprintf(stdout," rays Trace rays\n");
fprintf(stdout," plot Trace plot\n");
fprintf(stdout," clipping Trace clipping\n");
main (const int argc, char *const argv[])
{
DETECTOR *det;
- PICTURE *pic = NULL;
+ PHANTOM *phm = NULL;
RAYSUM *rs_global = NULL;
char str[256], *opt_outfile = NULL, opt_desc[MAXREMARK+1];
- char opt_picfilename[256];
+ char opt_phmfilename[256];
char *endptr, *endstr;
int opt_ndet, opt_nview;
int opt_nray = 1;
- int opt_trace = 0, opt_picnum = -1;
+ int opt_trace = 0, opt_phmnum = -1;
int opt_verbose = 0;
int opt_debug = 0;
double opt_rotangle = 1;
if (mpi_ct.my_rank == 0) {
#endif
strcpy(opt_desc, "");
- strcpy(opt_picfilename, "");
+ strcpy(opt_phmfilename, "");
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
char *endptr = NULL;
switch (c) {
case O_PHANTOM:
- opt_picnum = opt_set_picture(optarg, argv[0]);
- pic = create_pic(opt_picnum);
+ opt_phmnum = opt_set_phantom (optarg, argv[0]);
+ phm = phm_create (opt_phmnum);
break;
- case O_PICFILE:
+ case O_PHMFILE:
#ifdef MPI_CT
if (mpi_ct.my_rank == 0)
- fprintf(stderr, "Can not read picture from file in MPI mode\n");
+ fprintf(stderr, "Can not read phantom from file in MPI mode\n");
exit(1);
#endif
- strncpy(opt_picfilename, optarg, sizeof(opt_picfilename));
- pic = create_pic_from_file(opt_picfilename);
+ strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
+ phm = phm_create_from_file(opt_phmfilename);
break;
case O_VERBOSE:
opt_verbose = 1;
}
}
- if (pic == NULL) {
+ if (phm == NULL) {
fprintf(stderr, "No phantom defined\n");
usage(argv[0]);
exit(1);
snprintf(str, sizeof(str),
"Raysum_Collect: NDet=%d, Nview=%d, NRay=%d, RotAngle=%.2f, ",
opt_ndet, opt_nview, opt_nray, opt_rotangle);
- if (opt_picfilename[0]) {
+ if (opt_phmfilename[0]) {
strncat(str, "Phantom=", sizeof(str));
- strncat(str, opt_picfilename, sizeof(str));
- } else if (opt_picnum != -1) {
+ strncat(str, opt_phmfilename, sizeof(str));
+ } else if (opt_phmnum != -1) {
strncat(str, "Phantom=", sizeof(str));
- strncat(str, name_of_picture(opt_picnum), sizeof(str));
+ strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
}
if (opt_desc[0]) {
strncat(str, ": ", sizeof(str));
MPI_Bcast(&opt_nview, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_ndet, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_nray, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_picnum, 1, MPI_INT, 0, mpi_ct.comm);
+ MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm);
- if (mpi_ct.my_rank > 0 && opt_picnum > 0)
- pic = create_pic(opt_picnum);
+ if (mpi_ct.my_rank > 0 && opt_phmnum > 0)
+ phm = phm_create (opt_phmnum);
#endif
opt_rotangle *= PI;
- det = detect_create (pic, opt_ndet, opt_nview, opt_nray, opt_rotangle);
+ det = detect_create (phm, opt_ndet, opt_nview, opt_nray, opt_rotangle);
#ifdef MPI_CT
mpi_ct_calc_work_units(opt_nview);
if (opt_verbose)
mpi_t1 = MPI_Wtime();
- raysum_collect (rs_local, det, pic, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE);
+ raysum_collect (rs_local, det, phm, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE);
if (opt_verbose) {
mpi_t2 = MPI_Wtime();
mpi_t = mpi_t2 - mpi_t1;
}
#else
rs_global = raysum_create_from_det (opt_outfile, det);
- raysum_collect (rs_global, det, pic, 0, opt_trace, FALSE);
+ raysum_collect (rs_global, det, phm, 0, opt_trace, FALSE);
#endif
#ifdef MPI_CT
detect_free (det);
- if (opt_trace >= TRACE_PIC)
+ if (opt_trace >= TRACE_PHM)
{
crt_set_cpos (1, 1);
printf("Finished\n");
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2sdf.c,v 1.5 2000/04/30 19:17:54 kevin Exp $
+** $Id: phm2sdf.c,v 1.6 2000/05/03 08:49:50 kevin Exp $
** $Log: phm2sdf.c,v $
+** Revision 1.6 2000/05/03 08:49:50 kevin
+** Code cleanup
+**
** Revision 1.5 2000/04/30 19:17:54 kevin
** *** empty log message ***
**
#define O_TRACE 5
#define O_VERBOSE 6
#define O_HELP 7
-#define O_PICFILE 8
+#define O_PHMFILE 8
#define O_FILTER_DOMAIN 9
#define O_FILTER_BW 10
#define O_FILTER_PARAM 11
static struct option my_options[] =
{
{"phantom", 1, 0, O_PHANTOM},
- {"picfile", 1, 0, O_PICFILE},
+ {"phmfile", 1, 0, O_PHMFILE},
{"desc", 1, 0, O_DESC},
{"nsample", 1, 0, O_NSAMPLE},
{"filter", 1, 0, O_FILTER},
void
usage (const char *program)
{
- fprintf(stdout,"usage: %s outfile nx ny [--phantom phantom-name] [--picfile filename] [--filter filter-name] [OPTIONS]\n",kbasename(program));
- fprintf(stdout,"Generate phantom image from a predefined --phantom or a --picfile\n");
+ fprintf(stdout,"usage: %s outfile nx ny [--phantom phantom-name] [--phmfile filename] [--filter filter-name] [OPTIONS]\n",kbasename(program));
+ fprintf(stdout,"Generate phantom image from a predefined --phantom or a --phmfile\n");
fprintf(stdout,"\n");
fprintf(stdout," outfile Name of output file for image\n");
fprintf(stdout," nx Number of pixels X-axis\n");
fprintf(stdout," rowland Rowland head phantom\n");
fprintf(stdout," browland Bordered Rowland head phantom\n");
fprintf(stdout," unitpulse Unit pulse phantom\n");
- fprintf(stdout," --picfile Generate Phantom from picture file\n");
+ fprintf(stdout," --phmfile Generate Phantom from phantom file\n");
fprintf(stdout," --filter Generate Phantom from a filter function\n");
fprintf(stdout," abs_bandlimit Abs * Bandlimiting\n");
fprintf(stdout," abs_sinc Abs * Sinc\n");
fprintf(stdout," --trace Trace level to use\n");
fprintf(stdout," none No tracing (default)\n");
fprintf(stdout," text Trace text level\n");
- fprintf(stdout," pic Trace picture\n");
+ fprintf(stdout," phm Trace phantom\n");
fprintf(stdout," rays Trace rays\n");
fprintf(stdout," plot Trace plot\n");
fprintf(stdout," clipping Trace clipping\n");
main (const int argc, char *const argv[])
{
IMAGE *im_global = NULL;
- PICTURE *pic = NULL;
+ PHANTOM *phm = NULL;
int opt_nx = 0, opt_ny = 0;
int opt_nsample = 1;
- int opt_picnum = -1;
+ int opt_phmnum = -1;
int opt_filter = -1;
int opt_filter_domain = D_SPATIAL;
char *opt_outfile = NULL;
int opt_debug = 0;
char str[256];
- char opt_desc[256], opt_picfilename[256];
+ char opt_desc[256], opt_phmfilename[256];
char *endstr, *endptr;
double opt_filter_param = 1;
double opt_filter_bw = 1.;
#endif
strcpy(opt_desc, "");
- strcpy(opt_picfilename, "");
+ strcpy(opt_phmfilename, "");
while (1) {
int c = getopt_long(argc, argv, "", my_options, NULL);
char *endptr = NULL;
switch (c) {
case O_PHANTOM:
- opt_picnum = opt_set_picture(optarg, argv[0]);
+ opt_phmnum = opt_set_phantom(optarg, argv[0]);
break;
- case O_PICFILE:
- strncpy(opt_picfilename, optarg, sizeof(opt_picfilename));
- pic = create_pic_from_file(opt_picfilename);
+ case O_PHMFILE:
+ strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
+ phm = phm_create_from_file(opt_phmfilename);
#ifdef MPI_CT
if (mpi_ct.my_rank == 0)
- fprintf(stderr, "Can't use picture from file in MPI mode\n");
+ fprintf(stderr, "Can't use phantom from file in MPI mode\n");
exit(1);
#endif
break;
}
}
- if (pic == NULL && opt_picnum == -1 && opt_filter == -1) {
+ if (phm == NULL && opt_phmnum == -1 && opt_filter == -1) {
fprintf(stderr, "No phantom defined\n");
usage(argv[0]);
exit(1);
}
- if (opt_trace >= TRACE_PIC)
- show_pic(pic);
+#if HAVE_INTERACTIVE_GRAPHICS
+ if (opt_trace >= TRACE_PHM)
+ show_phm(phm);
+#endif
if (optind + 3 != argc) {
usage(argv[0]);
}
snprintf(str, sizeof(str), "nx=%d, ny=%d, nsample=%d, ", opt_nx, opt_ny, opt_nsample);
- if (opt_picfilename[0]) {
+ if (opt_phmfilename[0]) {
strncat(str, "phantom=", sizeof(str));
- strncat(str, opt_picfilename, sizeof(str));
+ strncat(str, opt_phmfilename, sizeof(str));
}
- else if (opt_picnum != -1) {
+ else if (opt_phmnum != -1) {
strncat(str, "phantom=", sizeof(str));
- strncat(str, name_of_picture(opt_picnum), sizeof(str));
+ strncat(str, name_of_phantom(opt_phmnum), sizeof(str));
}
else if (opt_filter != -1) {
strncat(str, "filter=", sizeof(str));
MPI_Bcast(&opt_nx, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_ny, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_nsample, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_picnum, 1, MPI_INT, 0, mpi_ct.comm);
+ MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_filter_domain, 1, MPI_INT, 0, mpi_ct.comm);
MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm);
im_global = image_create (opt_outfile, opt_nx, opt_ny);
#endif
- if (opt_picnum > 0)
- pic = create_pic(opt_picnum);
+ if (opt_phmnum > 0)
+ phm = phm_create (opt_phmnum);
#ifdef MPI_CT
else {
if (mpi_ct.my_rank == 0)
- fprintf(stderr, "picnum < 0\n");
+ fprintf(stderr, "phmnum < 0\n");
exit(1);
}
#endif
#ifdef MPI_CT
- if (pic->type == P_UNIT_PULSE) {
+ if (phm->type == P_UNIT_PULSE) {
if (mpi_ct.my_rank == 0) {
im_global->v[opt_nx/2][opt_ny/2] = 1.;
im_global->calctime = 0;
}
} else if (opt_filter != -1) {
if (mpi_ct.my_rank == 0) {
- image_filter_init (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+ image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
im_global->calctime = 0;
}
} else {
if (opt_verbose)
mpi_t1 = MPI_Wtime();
- pic_to_image (pic, im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],
+ phm_to_image (phm, im_local, mpi_ct.start_work_unit[mpi_ct.my_rank],
mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
if (opt_verbose) {
mpi_t2 = MPI_Wtime();
mpi_t = mpi_t2 - mpi_t1;
MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
if (mpi_ct.my_rank == 0)
- printf("Time to compile pic = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
+ printf("Time to compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
}
mpi_gather_image(im_global, im_local, opt_debug);
}
#else
- if (pic->type == P_UNIT_PULSE) {
+ if (phm->type == P_UNIT_PULSE) {
im_global->v[opt_nx/2][opt_ny/2] = 1.;
im_global->calctime = 0;
} else if (opt_filter != -1) {
- image_filter_init (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
+ image_filter_response (im_global, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace);
im_global->calctime = 0;
} else {
- pic_to_image (pic, im_global, 0, opt_nx, opt_nsample, opt_trace);
+ phm_to_image (phm, im_global, 0, opt_nx, opt_nsample, opt_trace);
}
#endif
strncpy (im_global->remark, opt_desc, sizeof(im_global->remark));
image_save (im_global);
- if (opt_trace >= TRACE_PIC)
+ if (opt_trace >= TRACE_PHM)
{
crt_set_cpos (1, 1);
}
fprintf (stdout, "Time to compile image = %.2f sec\n\n", im_global->calctime);
#endif
- if (opt_trace >= TRACE_PIC)
+ if (opt_trace >= TRACE_PHM)
{
double dmin, dmax;
int nx, ny;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sdf-1.c,v 1.1 2000/04/28 13:02:44 kevin Exp $
+** $Id: sdf-1.c,v 1.2 2000/05/03 08:49:50 kevin Exp $
** $Log: sdf-1.c,v $
-** Revision 1.1 2000/04/28 13:02:44 kevin
-** Initial revision
+** Revision 1.2 2000/05/03 08:49:50 kevin
+** Code cleanup
+**
+** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
+** Initial CVS import for first public release
+**
**
**
** This program is free software; you can redistribute it and/or modify
#include "ct.h"
+#define O_LOG 4
+#define O_EXP 5
#define O_INVERT 6
#define O_VERBOSE 7
#define O_HELP 8
{
{"invert", 0, 0, O_INVERT},
{"verbose", 0, 0, O_VERBOSE},
+ {"log", 0, 0, O_LOG},
+ {"exp", 0, 0, O_EXP},
{"help", 0, 0, O_HELP},
{"version", 0, 0, O_VERSION},
{0, 0, 0, 0}
fprintf(stdout, "Generate a SDF2D file from a SDF2D file\n");
fprintf(stdout, "\n");
fprintf(stdout, " --invert Invert image\n");
+ fprintf(stdout, " --log Natural logrithm of image\n");
+ fprintf(stdout, " --exp Natural exponential of image\n");
fprintf(stdout, " --verbose Verbose modem\n");
fprintf(stdout, " --version Print version\n");
fprintf(stdout, " --help Print this help message\n");
char *out_file;
int opt_verbose = 0;
int opt_invert = 0;
+ int opt_log = 0;
+ int opt_exp = 0;
while (1)
{
case O_INVERT:
opt_invert = 1;
break;
+ case O_LOG:
+ opt_log = 1;
+ break;
+ case O_EXP:
+ opt_exp = 1;
+ break;
case O_VERBOSE:
opt_verbose = 1;
break;
out_file = argv[optind + 1];
- if (opt_invert) {
+ if (opt_invert || opt_log || opt_exp) {
int ix, iy;
im_in = image_load (in_file);
im_out = image_create (out_file, im_in->nx, im_in->ny);
- for (ix = 0; ix < im_in->nx; ix++)
- for (iy = 0; iy < im_in->ny; iy++)
- im_out->v[ix][iy] = - im_in->v[ix][iy];
-
+ if (opt_invert) {
+ for (ix = 0; ix < im_in->nx; ix++)
+ for (iy = 0; iy < im_in->ny; iy++)
+ im_out->v[ix][iy] = - im_in->v[ix][iy];
+ }
+ if (opt_log) {
+ for (ix = 0; ix < im_in->nx; ix++)
+ for (iy = 0; iy < im_in->ny; iy++)
+ im_out->v[ix][iy] = log (im_in->v[ix][iy]);
+ }
+ if (opt_exp) {
+ for (ix = 0; ix < im_in->nx; ix++)
+ for (iy = 0; iy < im_in->ny; iy++)
+ im_out->v[ix][iy] = exp (im_in->v[ix][iy]);
+ }
+
image_save(im_out);
}