X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=include%2Fir.h;h=ffa83fb63d156cb3891d212ae8091f860a31b578;hp=96b21290e5b4618af1a18c95daf1cd007bff64fc;hb=031437896d0dc6cac70c16e5604b10f5aa4d0767;hpb=e559ff1655d5c6103447912e345a1229fdaa4a35 diff --git a/include/ir.h b/include/ir.h index 96b2129..ffa83fb 100644 --- a/include/ir.h +++ b/include/ir.h @@ -1,51 +1,15 @@ /***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: ir.h,v 1.14 2000/05/11 14:07:00 kevin Exp $ -** $Log: ir.h,v $ -** Revision 1.14 2000/05/11 14:07:00 kevin -** Added support for Windows NT -** -** Revision 1.13 2000/05/08 20:00:48 kevin -** ANSI C changes -** -** Revision 1.12 2000/05/07 12:46:19 kevin -** made c++ compatible -** -** Revision 1.11 2000/05/05 02:37:31 kevin -** renamed phmelm to pelm -** -** Revision 1.10 2000/05/04 18:16:34 kevin -** renamed filter definitions -** -** 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 +** FILE IDENTIFICATION ** -** Revision 1.7 2000/05/03 19:51:41 kevin -** function renaming for phantoms and phantom elements +** Name: ir.h +** Purpose: Master Image Reconstruction Header +** Programmer: Kevin Rosenberg +** Date Started: July 1, 1984 ** -** 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 *** -** -** Revision 1.4 2000/05/02 15:31:39 kevin -** code cleaning -** -** Revision 1.3 2000/04/29 23:24:29 kevin -** *** empty log message *** -** -** Revision 1.2 2000/04/28 14:14:16 kevin -** *** empty log message *** -** -** Revision 1.1.1.1 2000/04/28 13:02:43 kevin -** Initial CVS import for first public release +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg ** +** $Id: ir.h,v 1.26 2000/06/13 16:20:31 kevin Exp $ ** ** ** This program is free software; you can redistribute it and/or modify @@ -62,62 +26,13 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ -/* ir.h Header File for Image Reconstruction System - * Programmer: Kevin Rosenberg - * Date Started: 7-1-84 - */ - #ifndef IR_H #define IR_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef MPI_CT -#define MPI_MAX_PROCESS 128 -struct mpi_ct_st -{ - int my_rank; - int nproc; - int base_local_work_units; - int remainder_work_units; - int local_work_units[MPI_MAX_PROCESS]; - int start_work_unit[MPI_MAX_PROCESS]; - MPI_Comm comm; -}; - -extern struct mpi_ct_st mpi_ct; -void mpi_ct_calc_work_units(const unsigned int global_work_units); -#endif - - -struct histo_st { - int *b; /* Histogram array (# of elements in each bin) */ - int nbin; /* Number of histogram bins */ - double xmin, xmax, xinc; /* Limits of histogram boundaries */ -}; - -typedef struct histo_st HISTOGRAM; - -/*---------------------------------------------------------------------------*/ static const int POINTS_PER_CIRCLE=90; #define MAXREMARK 99 -typedef FMTX_2D IMAGE_ARRAY; /* use 2d floating point matrix */ -typedef float IMAGE_ELEM_VAL; /* use floats for image storing */ - -struct image_st { - IMAGE_ARRAY 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 phm coord */ - char remark[MAXREMARK+1]; /* description of voxel data */ - float calctime; /* time to calculate voxels in seconds */ -}; -typedef struct image_st IMAGE; - typedef enum { RECTANGLE, TRIANGLE, @@ -126,7 +41,10 @@ typedef enum { SEGMENT } PElmType; -struct pelm_st { + +class PhmElement +{ + public: PElmType type; /* pelm type (box, ellipse, etc) */ double atten; /* X-ray attenuation coefficient */ double cx,cy; /* center of pelm */ @@ -138,9 +56,9 @@ struct pelm_st { double radius; /* " */ GRFMTX_2D p_to_o; /* map from phantom to standard pelm coords */ GRFMTX_2D o_to_p; /* map from std pelm coords to phantom coords */ - struct pelm_st *next; /* pointer to next pelm in phantom */ + class PhmElement *next; /* pointer to next pelm in phantom */ }; -typedef struct pelm_st PELM; +typedef class PhmElement PELM; typedef enum { P_PELMS, /* Phantom made of Pelms */ @@ -148,14 +66,18 @@ typedef enum { P_FILTER /* defined only by this type */ } PhmType; -struct phm_st { /* Phantom structure */ + +/* Phantom class */ +class Phantom +{ +public: PELM *pelm_list; /* pelm linked-list */ PhmType type; int n_pelm; /* number of pelms in phantom */ double xmin, xmax, ymin, ymax; /* extent of pelms in pelm coordinates */ double radius; /* " " */ }; -typedef struct phm_st PHANTOM; +typedef class Phantom PHANTOM; /*----------------------------------------------------------------------*/ @@ -168,12 +90,13 @@ typedef struct phm_st PHANTOM; typedef float DETECT_TYPE; -struct detarray_st { +struct DetectorArray +{ DETECT_TYPE *detval; /* Pointer to array of values recorded by detector */ int ndet; /* Number of detectors in array */ double view_angle; /* View angle in radians */ }; -typedef struct detarray_st DETARRAY; +typedef struct DetectorArray DETARRAY; typedef enum { @@ -182,7 +105,10 @@ typedef enum { DETECTOR_EQUILINEAR } ScannerGeometry; -struct detector_st { + +class Detector +{ + public: ScannerGeometry geometry; /* Geometry of detectory */ int ndet; /* Number of detectors in array */ int nview; /* Number of rotated views */ @@ -200,14 +126,17 @@ struct detector_st { double angle; /* Starting angle */ } init; }; -typedef struct detector_st DETECTOR; +typedef class Detector DETECTOR; -struct raysum_st { - int fd; - int file_mode; - int header_size; - int geometry; - struct detarray_st **view; /* Pointer to array of detarray_st pointers */ + +class Projections +{ + public: + int fd; /* Disk file descriptor */ + int file_mode; /* Current file mode (read or write) */ + int header_size; /* Size of disk file header */ + int geometry; /* Geometry of scanner */ + struct DetectorArray **view; /* Pointer to array of detarray_st pointers */ char remark[MAXREMARK+1]; /* description of raysum data */ double calctime; /* time required to calculate raysums */ @@ -221,7 +150,8 @@ struct raysum_st { double det_inc; /* increment between detectors */ double phmlen; /* Length of PHANTOM edge (phm is square) */ }; -typedef struct raysum_st RAYSUM; +typedef class Projections RAYSUM; + /*----------------------------------------------------------------------*/ /* USER SYMBOLS */ @@ -256,24 +186,27 @@ static const char D_FREQ_STR[]= "freq"; static const char D_SPATIAL_STR[]= "spatial"; typedef enum { - D_FREQ, + D_FREQ = 1, D_SPATIAL } DomainType; typedef enum { - FUNC_EVEN, /* function types, f[-n] = f[n] */ + FUNC_EVEN = 1, /* function types, f[-n] = f[n] */ FUNC_ODD, /* f[-n] = -f[n] */ FUNC_BOTH /* function has both odd & even components */ } FunctionSymmetry; /* interpolation methods */ +#undef HAVE_BSPLINE_INTERP typedef enum { /* Interpolation methods */ - I_NEAREST, /* Nearest neighbor */ - I_LINEAR, /* Linear interpolation */ + I_NEAREST = 1, /* Nearest neighbor */ +#if HAVE_BSPLINE_INTERP I_BSPLINE, I_1BSPLINE, /* 1st order B-Spline */ I_2BSPLINE, - I_3BSPLINE + I_3BSPLINE, +#endif + I_LINEAR /* Linear interpolation */ } InterpolationType; /* Constants for sizing PHANTOM */ @@ -351,91 +284,46 @@ const static int RAYSUM_TRACE_ROW_CURR_VIEW=17; const static int RAYSUM_TRACE_ROW_ATTEN=18; + /************************************************************************* * FUNCTION DECLARATIONS ************************************************************************/ - -void usage (const char *program); - -/* From reconstr.c */ -IMAGE *image_reconst (IMAGE *im, RAYSUM *rs, int filt_type, double filt_param, const InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace); - -/* From bproj.c */ -void backproj_init (const RAYSUM *rs, IMAGE *im, const BackprojType bproj_method); -int backproj_calc (const RAYSUM *rs, IMAGE *im, const double *t, const double view_angle, - const int interp_type, const int bproj_method); -void backproj_term (const RAYSUM *rs, IMAGE *im, const int bproj_method); -void backproj_init_trig (const RAYSUM *rs, IMAGE *im); -int backproj_calc_trig (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_trig (const RAYSUM *rs, IMAGE *im); -void backproj_init_table (const RAYSUM *rs, IMAGE *im); -int backproj_calc_table (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_table (const RAYSUM *rs, IMAGE *im); -void backproj_init_d (const RAYSUM *rs, IMAGE *im); -int backproj_calc_d (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_d (const RAYSUM *rs, IMAGE *im); -void backproj_init_d2 (const RAYSUM *rs, IMAGE *im); -int backproj_calc_d2 (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_d2 (const RAYSUM *rs, IMAGE *im); -void backproj_init_id (const RAYSUM *rs, IMAGE *im); -int backproj_calc_id (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_id (const RAYSUM *rs, IMAGE *im); -void backproj_init_id2 (const RAYSUM *rs, IMAGE *im); -int backproj_calc_id2 (const RAYSUM *rs, IMAGE *im, const double *t, - const double view_angle, const int interp_type); -void backproj_term_id2 (const RAYSUM *rs, IMAGE *im); - -/* 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 FunctionSymmetry func_type); -double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np); - -/* 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(const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType 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); +/* convolve.cpp */ +double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type); + +/* dialogs.cpp */ +int phm_add_pelm_kb (PHANTOM *phm); +PHANTOM *phm_select (void); +int interpolation_select (void); +int filter_select (double *filter_param); + +/* filter.cpp */ +double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType 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 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); -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); +/* options.cpp */ +int opt_set_trace(const char *optarg); 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); +int opt_set_phantom(const char *optarg); +InterpolationType opt_set_interpolation(const char *optarg); const char *name_of_interpolation(int interp_type); -int opt_set_filter(const char *optarg, const char *program); +FilterType opt_set_filter(const char *optarg); const char *name_of_filter(const int filter); -DomainType opt_set_filter_domain(const char *optarg, const char *program); +DomainType opt_set_filter_domain(const char *optarg); const char *name_of_filter_domain(const DomainType domain); -int opt_set_backproj(const char *optarg, const char *program); +BackprojType opt_set_backproj(const char *optarg); const char *name_of_backproj(const BackprojType backproj); -/* phm.c */ +/* phm.cpp */ PHANTOM *phm_create(const int phmid); PHANTOM *phm_create_from_file(const char *fname); PHANTOM *phm_init(void); +void phm_free (PHANTOM *phm); int phm_add_pelm_file(PHANTOM *phm, const char *fname); void phm_add_pelm (PHANTOM *phm, const char *type, const double cx, const double cy, const double u, const double v, const double rot, const double atten); @@ -447,34 +335,29 @@ void calc_arc(double x[], double y[], const int pts, const double xcent, const d void calc_ellipse(double x[], double y[], const int pts, const double u, const double v); int circle_pts(double theta); void phm_print(PHANTOM *phm); -#if HAVE_INTERACTIVE_GRAPHICS +#if HAVE_SGP void phm_show(const PHANTOM *phm); void phm_draw(const PHANTOM *phm); #endif -/* phm2image.c */ -void phm_to_image(const PHANTOM *phm, IMAGE *im, const int col_start, const int col_count, - const int nsample, const int trace); -int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type); - -/* phmstd.c */ +/* phmstd.cpp */ void phm_std_herman (PHANTOM *phm); void phm_std_rowland (PHANTOM *phm); void phm_std_rowland_bordered (PHANTOM *phm); -/* raycollect.c */ +/* raycollect.cpp */ 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 (PELM *pelm, const double x1, const double y1, const double x2, const double y2); -int pelm_clip_line (const PELM *pelm, double *x1, double *y1, double *x2, double *y2); +int pelm_clip_line (const PELM *pelm, 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 *detector_create(const PHANTOM *phm, int geometry, int ndet, int nview, int nsample, const double rot_anglen); +/* scanner.cpp */ +DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen); void detector_free(DETECTOR *det); -/* rayio.c */ +/* rayio.cpp */ RAYSUM *raysum_create(const char *fname, const int nview, const int ndet); RAYSUM *raysum_create_from_det(const char *fname, const DETECTOR *det); RAYSUM *raysum_open(const char *filename); @@ -486,14 +369,53 @@ int raysum_read_header(RAYSUM *rs); int raysum_write_header(RAYSUM *rs); int raysum_read(RAYSUM *rs); int raysum_write(RAYSUM *rs); +void raysum_print(const RAYSUM *rs); +void raysum_print_info(const RAYSUM *rs); DETARRAY *detarray_alloc(const int n); 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); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +/* From phm2image.cpp */ +void phm_to_imagefile (const PHANTOM *phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace); +int pelm_is_point_inside(PELM *obj, const double x, const double y, const CoordType coord_type); + +/* image.cpp */ +void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace); +int image_display (const ImageFile& im); +int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax); + +/* From reconstr.cpp */ +ImageFile& proj_reconst (ImageFile& im, RAYSUM *rs, const FilterType filt_type, double filt_param, InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace); + +/* From bproj.cpp */ +void backproj_init (const RAYSUM *rs, ImageFile& im, const BackprojType bproj_method); +int backproj_calc (const RAYSUM *rs, ImageFile& im, const double *t, const double view_angle, const int interp_type, const int bproj_method); +void backproj_term (const RAYSUM *rs, ImageFile& im, const int bproj_method); + +void backproj_init_trig (const RAYSUM *rs, ImageFile& im); +int backproj_calc_trig (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_trig (const RAYSUM *rs, ImageFile& im); +void backproj_init_table (const RAYSUM *rs, ImageFile& im); +int backproj_calc_table (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_table (const RAYSUM *rs, ImageFile& im); +void backproj_init_d (const RAYSUM *rs, ImageFile& im); +int backproj_calc_d (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_d (const RAYSUM *rs, ImageFile& im); +void backproj_init_d2 (const RAYSUM *rs, ImageFile& im); +int backproj_calc_d2 (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_d2 (const RAYSUM *rs, ImageFile& im); +void backproj_init_id (const RAYSUM *rs, ImageFile& im); +int backproj_calc_id (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_id (const RAYSUM *rs, ImageFile& im); +void backproj_init_id2 (const RAYSUM *rs, ImageFile& im); +int backproj_calc_id2 (const RAYSUM *rs, ImageFile& im, const double *t, + const double view_angle, const int interp_type); +void backproj_term_id2 (const RAYSUM *rs, ImageFile& im); #endif