X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Fir.h;h=cd801f3f8ff921472a5fa64398eadbb42bd16699;hb=e5900ffc67707d6a27ec198ed6c1628e7331d2f5;hp=c7f63a04b87053081ddb20a2fc547506fb7f337c;hpb=d46f5229565d6fdd6c3d164ee0790433ff9118a2;p=ctsim.git diff --git a/include/ir.h b/include/ir.h index c7f63a0..cd801f3 100644 --- a/include/ir.h +++ b/include/ir.h @@ -2,8 +2,20 @@ ** 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.9 2000/05/04 04:29:18 kevin Exp $ ** $Log: ir.h,v $ +** Revision 1.9 2000/05/04 04:29:18 kevin +** *** empty log message *** +** +** Revision 1.8 2000/05/04 04:25:55 kevin +** Renamed phantom and phantom-element functions/variables +** +** Revision 1.7 2000/05/03 19:51:41 kevin +** function renaming for phantoms and phantom elements +** +** 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 *** ** @@ -85,43 +97,43 @@ struct image_st { 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 */ }; -struct object_st { - int type; /* object type (box, ellipse, etc) */ +struct phmelm_st { + int type; /* phmelm type (box, ellipse, etc) */ double atten; /* X-ray attenuation coefficient */ - double cx,cy; /* center of object */ - double u,v; /* size of object */ - double rot; /* object rotation angle (in radians) */ + double cx,cy; /* center of phmelm */ + double u,v; /* size of phmelm */ + double rot; /* phmelm rotation angle (in radians) */ double *x, *y; /* ptr to array of points in obj world coord */ int pts; /* number of points in outline arrays */ - double xmin, xmax, ymin, ymax; /* object limits */ + double xmin, xmax, ymin, ymax; /* phmelm 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 phantom to standard phmelm coords */ + GRFMTX_2D o_to_p; /* map from std phmelm coords to phantom coords */ } xform; - struct object_st *next; /* pointer to next object in picture */ + struct phmelm_st *next; /* pointer to next phmelm in phantom */ }; -typedef struct object_st OBJECT; +typedef struct phmelm_st PHMELM; -struct pic_st { /* Picture structure */ - OBJECT *objlist; /* object list */ +struct phm_st { /* Phantom structure */ + PHMELM *phmelm_list; /* phmelm linked-list */ int type; - int numobj; /* number of objects in picture */ - double xmin, xmax, ymin, ymax; /* extent of objects in object coordinates */ + int n_pelm; /* number of phmelms in phantom */ + double xmin, xmax, ymin, ymax; /* extent of phmelms in phmelm 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_PHMELMS 0 /* Phantom made of phmelms */ +#define P_UNIT_PULSE 1 /* Special PHANTOM, not made of phmelms */ #define P_FILTER 9 /* defined only by a type */ /*----------------------------------------------------------------------*/ @@ -136,11 +148,16 @@ typedef struct pic_st PICTURE; 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 */ @@ -149,8 +166,8 @@ struct detect_st { 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 */ @@ -172,9 +189,9 @@ struct raysum_st { 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; @@ -185,7 +202,7 @@ typedef struct raysum_st RAYSUM; /* USER SYMBOLS */ /*----------------------------------------------------------------------*/ -/* codes for object types, passed to add_obj() */ +/* codes for phmelm types, passed to add_obj() */ #define O_RECTANGLE 1 #define O_TRIANGLE 2 @@ -194,10 +211,10 @@ typedef struct raysum_st RAYSUM; #define O_SEGMENT 5 /* Codes for Coordinate Types */ -/* Defines coords for inside_obj() */ +/* Defines coords for pelm_is_point_inside() */ -#define OBJ_COORD -1 /* Normalized Object Coordinates */ -#define PIC_COORD -2 /* User's Picture Coordinates */ +#define PELM_COORD -1 /* Normalized Phmelm Coordinates */ +#define PHM_COORD -2 /* User's PHANTOM Coordinates */ /* Codes for Filter types */ @@ -237,19 +254,16 @@ typedef struct raysum_st RAYSUM; #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 */ - /* limits compared to object size */ +#define PERCENT_PHM_SIZE_INCR 0.0 /* Fractional increase in PHANTOM */ + /* limits compared to phmelm size */ #define N_EXTRA_DETECTORS 4 /* Number of extra detectors */ /* widths when calculating detlen */ -#define DET_PARALLEL 1 -#define DET_FAN 2 - #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" @@ -257,20 +271,20 @@ typedef struct raysum_st RAYSUM; #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" @@ -299,17 +313,17 @@ typedef struct raysum_st RAYSUM; #define O_BPROJ_DIFF2_STR "diff2" #define O_BPROJ_IDIFF2_STR "idiff2" -#define RS_TRACE_ROW_TITLE 1 -#define RS_TRACE_ROW_TITLE2 2 -#define RS_TRACE_ROW_PHANT_ID 4 -#define RS_TRACE_ROW_CHROMATIC 7 -#define RS_TRACE_ROW_SCATTER 8 -#define RS_TRACE_ROW_PHOT_STAT 9 -#define RS_TRACE_ROW_NDET 12 -#define RS_TRACE_ROW_NVIEW 13 -#define RS_TRACE_ROW_SAMPLES 14 -#define RS_TRACE_ROW_CURR_VIEW 17 -#define RS_TRACE_ROW_ATTEN 18 +#define RAYSUM_TRACE_ROW_TITLE 1 +#define RAYSUM_TRACE_ROW_TITLE2 2 +#define RAYSUM_TRACE_ROW_PHANT_ID 4 +#define RAYSUM_TRACE_ROW_CHROMATIC 7 +#define RAYSUM_TRACE_ROW_SCATTER 8 +#define RAYSUM_TRACE_ROW_PHOT_STAT 9 +#define RAYSUM_TRACE_ROW_NDET 12 +#define RAYSUM_TRACE_ROW_NVIEW 13 +#define RAYSUM_TRACE_ROW_SAMPLES 14 +#define RAYSUM_TRACE_ROW_CURR_VIEW 17 +#define RAYSUM_TRACE_ROW_ATTEN 18 /*----------------------------------------------------------------------*/ @@ -382,6 +396,7 @@ int main(const int argc, char * const argv[]); /* bspline.c */ int bspline(int samples, int zoom_factor, int spline_order, double input[], double output[]); + /* convolve.c */ double convolve(const double f1[], const double f2[], const double dx, const int n, const int np, const int func_type); double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np); @@ -389,34 +404,32 @@ void rotate2d(double x[], double y[], int pts, double angle); 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); -double sinc(double x, double mult); -double abscos_int(double u, double w); + +/* dialogs.c */ +int phm_add_pelm_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); -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); +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 integral_abscos(double u, double w); + /* 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); @@ -425,41 +438,48 @@ int opt_set_filter_domain(const char *optarg, const char *program); const char *name_of_filter_domain(const int domain); 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 phm_add_pelm_file(PHANTOM *phm, const char *fname); +void phm_add_pelm (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); +int pelm_make_points(PHMELM *obj); +void pelm_make_xform (PHMELM *obj); +PHMELM *pelm_alloc(void); void calc_arc(double x[], double y[], const int pts, const double xcent, const double ycent, 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); -/* ray.c */ -DETECTOR *detect_create(const PICTURE *pic, 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_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); +int pelm_is_point_inside(const PHMELM *obj, double x, double y, const int coord_type); + +/* phmstd.c */ +void phm_std_herman (PHANTOM *phm); +void phm_std_rowland (PHANTOM *phm); +void phm_std_rowland_bordered (PHANTOM *phm); + /* raycollect.c */ -int raysum_collect(RAYSUM *rs, const DETECTOR *det, const PICTURE *pic, const int start_view, - const int trace, const int unit_pulse); -void rayview(const PICTURE *pic, 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 raysum_collect(RAYSUM *rs, const DETECTOR *det, const PHANTOM *phm, const int start_view, const int trace, const int unit_pulse); +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); +double phm_ray_attenuation (const PHANTOM *phm, const double x1, const double y1, const double x2, const double y2); +double pelm_ray_attenuation (const PHMELM *obj, const double x1, const double y1, const double x2, const double y2); +int pelm_clip_line (const PHMELM *obj, double *x1, double *y1, double *x2, double *y2); +void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...); + +/* scanner.c */ +DETECTOR *detect_create(const PHANTOM *phm, int ndet, int nview, int nsample, const double rot_anglen); +void detect_free(DETECTOR *det); + /* rayio.c */ RAYSUM *raysum_create(const char *fname, const int nview, const int ndet); RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det); @@ -477,9 +497,6 @@ void detarray_free(DETARRAY *darray); 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