1 /*****************************************************************************
5 ** Purpose: Backprojection classes
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: June 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: backprojectors.h,v 1.10 2000/07/19 04:33:27 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 ******************************************************************************/
29 #ifndef __BACKPROJECTORS_H
30 #define __BACKPROJECTORS_H
32 #undef HAVE_BSPLINE_INTERP
34 #include "imagefile.h"
54 INTERP_NEAREST, // Nearest neighbor
55 #if HAVE_BSPLINE_INTERP
57 I_1BSPLINE, // 1st order B-Spline
61 INTERP_LINEAR, // Linear interpolation
62 INTERP_FREQ_PREINTERPOLATION,
65 static const char BPROJ_TRIG_STR[]= "trig";
66 static const char BPROJ_TABLE_STR[]= "table";
67 static const char BPROJ_DIFF_STR[]= "diff";
68 static const char BPROJ_DIFF2_STR[]= "diff2";
69 static const char BPROJ_IDIFF2_STR[]= "idiff2";
70 static const char BPROJ_IDIFF3_STR[]= "idiff3";
72 static const char INTERP_NEAREST_STR[]= "nearest";
73 static const char INTERP_LINEAR_STR[]= "linear";
74 static const char INTERP_BSPLINE_STR[]= "bspline";
75 static const char INTERP_FREQ_PREINTERPOLATION_STR[]= "freq_preinterpolation";
77 Backprojector (const Projections& proj, ImageFile& im, const char* const backprojName, const char* const interpName, const int interpFactor);
79 ~Backprojector (void);
81 void BackprojectView (const double* const viewData, const double viewAngle);
83 bool fail(void) const {return m_fail;}
84 const string& failMessage(void) const {return m_failMessage;}
87 string m_nameBackproject;
88 string m_nameInterpolation;
89 BackprojectID m_idBackproject;
90 InterpolationID m_idInterpolation;
91 Backproject* m_pBackprojectImplem;
95 static const InterpolationID convertInterpolationNameToID (const char* const interpName);
96 static const char* convertInterpolationIDToName (const InterpolationID interpID);
97 static const BackprojectID convertBackprojectNameToID (const char* const bprojName);
98 static const char* convertBackprojectIDToName (const BackprojectID bprojID);
100 bool initBackprojector (const Projections& proj, ImageFile& im, const char* const backprojName, const char* const interpName, const int interpFactor);
107 Backproject (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor);
109 virtual ~Backproject ();
111 virtual void BackprojectView (const double* const viewData, const double viewAngle) {};
114 void ScaleImageByRotIncrement (void);
115 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int ni);
116 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int ni);
118 const Projections& proj;
120 Backprojector::InterpolationID interpType;
126 int iDetCenter; // index refering to L=0 projection
128 double xMin, xMax, yMin, yMax; // Retangular coords of phantom
129 double xInc, yInc; // size of cells
133 Backproject (const Backproject& rhs);
134 Backproject& operator= (const Backproject& rhs);
138 class BackprojectTrig : public Backproject
141 BackprojectTrig (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor)
142 : Backproject::Backproject (proj, im, interpType, interpFactor)
145 void BackprojectView (const double* const t, double view_angle);
149 class BackprojectTable : public Backproject
152 BackprojectTable (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor);
153 ~BackprojectTable ();
155 void BackprojectView (const double* const t, double view_angle);
158 Array2d<kfloat64> arrayR;
159 Array2d<kfloat64> arrayPhi;
165 class BackprojectDiff : public Backproject
168 BackprojectDiff (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor);
171 void BackprojectView (const double* const t, double view_angle);
176 double im_xinc, im_yinc;
179 class BackprojectDiff2 : public BackprojectDiff
182 BackprojectDiff2 (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor)
183 : BackprojectDiff::BackprojectDiff (proj, im, interpType, interpFactor)
186 void BackprojectView (const double* const t, double view_angle);
189 class BackprojectIntDiff2 : public BackprojectDiff
192 BackprojectIntDiff2 (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor)
193 : BackprojectDiff::BackprojectDiff (proj, im, interpType, interpFactor)
196 void BackprojectView (const double* const t, double view_angle);
200 class BackprojectIntDiff3 : public BackprojectDiff
203 BackprojectIntDiff3 (const Projections& proj, ImageFile& im, Backprojector::InterpolationID interpType, const int interpFactor)
204 : BackprojectDiff::BackprojectDiff (proj, im, interpType, interpFactor)
207 void BackprojectView (const double* const t, double view_angle);