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-2001 Kevin Rosenberg
12 ** $Id: backprojectors.h,v 1.20 2001/02/09 01:54:20 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"
44 static const int BPROJ_INVALID;
45 static const int BPROJ_TRIG;
46 static const int BPROJ_TABLE;
47 static const int BPROJ_DIFF;
48 static const int BPROJ_DIFF2;
49 static const int BPROJ_IDIFF2;
50 static const int BPROJ_IDIFF3;
52 static const int INTERP_INVALID;
53 static const int INTERP_NEAREST;
54 static const int INTERP_LINEAR;
55 static const int INTERP_CUBIC;
56 static const int INTERP_FREQ_PREINTERPOLATION;
57 #if HAVE_BSPLINE_INTERP
58 static const int INTERP_BSPLINE;
59 static const int INTERP_1BSPLINE;
60 static const int INTERP_2BSPLINE;
61 static const int INTERP_3BSPLINE;
64 Backprojector (const Projections& proj, ImageFile& im, const char* const backprojName, const char* const interpName, const int interpFactor);
68 void BackprojectView (const double* const viewData, const double viewAngle);
70 bool fail() const {return m_fail;}
71 const std::string& failMessage() const {return m_failMessage;}
73 static const int getBackprojectCount() {return s_iBackprojectCount;}
74 static const char** getBackprojectNameArray() {return s_aszBackprojectName;}
75 static const char** getBackprojectTitleArray() {return s_aszBackprojectTitle;}
76 static int convertBackprojectNameToID (const char* const bprojName);
77 static const char* convertBackprojectIDToName (const int bprojID);
78 static const char* convertBackprojectIDToTitle (const int bprojID);
80 static const int getInterpCount() {return s_iInterpCount;}
81 static const char** getInterpNameArray() {return s_aszInterpName;}
82 static const char** getInterpTitleArray() {return s_aszInterpTitle;}
83 static int convertInterpNameToID (const char* const interpName);
84 static const char* convertInterpIDToName (const int interpID);
85 static const char* convertInterpIDToTitle (const int interpID);
89 std::string m_nameBackproject;
90 std::string m_nameInterpolation;
92 int m_idInterpolation;
93 Backproject* m_pBackprojectImplem;
95 std::string m_failMessage;
97 static const char* s_aszBackprojectName[];
98 static const char* s_aszBackprojectTitle[];
99 static const int s_iBackprojectCount;
101 static const char* s_aszInterpName[];
102 static const char* s_aszInterpTitle[];
103 static const int s_iInterpCount;
105 bool initBackprojector (const Projections& proj, ImageFile& im, const char* const backprojName, const char* const interpName, const int interpFactor);
112 Backproject (const Projections& proj, ImageFile& im, int interpID, const int interpFactor);
114 virtual ~Backproject ();
116 virtual void BackprojectView (const double* const viewData, const double viewAngle) {};
119 void ScaleImageByRotIncrement ();
120 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int ni);
121 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int ni);
123 const Projections& proj;
131 int iDetCenter; // index refering to L=0 projection
133 double xMin, xMax, yMin, yMax; // Retangular coords of phantom
134 double xInc, yInc; // size of cells
136 double m_dFocalLength;
139 Backproject (const Backproject& rhs);
140 Backproject& operator= (const Backproject& rhs);
144 class BackprojectTrig : public Backproject
147 BackprojectTrig (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
148 : Backproject (proj, im, interpID, interpFactor)
151 void BackprojectView (const double* const t, const double view_angle);
155 class BackprojectTable : public Backproject
158 BackprojectTable (const Projections& proj, ImageFile& im, int interpID, const int interpFactor);
159 virtual ~BackprojectTable ();
161 void BackprojectView (const double* const t, const double view_angle);
164 Array2d<kfloat64> arrayR;
165 Array2d<kfloat64> arrayPhi;
171 class BackprojectDiff : public Backproject
174 BackprojectDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor);
177 void BackprojectView (const double* const t, const double view_angle);
182 double im_xinc, im_yinc;
185 class BackprojectDiff2 : public BackprojectDiff
188 BackprojectDiff2 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
189 : BackprojectDiff (proj, im, interpID, interpFactor)
192 void BackprojectView (const double* const t, const double view_angle);
195 class BackprojectIntDiff2 : public BackprojectDiff
198 BackprojectIntDiff2 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
199 : BackprojectDiff (proj, im, interpID, interpFactor)
202 void BackprojectView (const double* const t, const double view_angle);
206 class BackprojectIntDiff3 : public BackprojectDiff
209 BackprojectIntDiff3 (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
210 : BackprojectDiff (proj, im, interpID, interpFactor)
213 void BackprojectView (const double* const t, const double view_angle);
216 class BackprojectEquilinear : public BackprojectTable
219 BackprojectEquilinear (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
220 : BackprojectTable (proj, im, interpID, interpFactor)
223 void BackprojectView (const double* const t, const double view_angle);
225 virtual ~BackprojectEquilinear()
229 class BackprojectEquiangular : public BackprojectTable
232 BackprojectEquiangular (const Projections& proj, ImageFile& im, int interpID, const int interpFactor)
233 : BackprojectTable (proj, im, interpID, interpFactor)
236 void BackprojectView (const double* const t, const double view_angle);
238 virtual ~BackprojectEquiangular()