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-2009 Kevin Rosenberg
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
27 #ifndef __BACKPROJECTORS_H
28 #define __BACKPROJECTORS_H
30 #undef HAVE_BSPLINE_INTERP
32 #include "imagefile.h"
38 struct ReconstructionROI;
43 static const int BPROJ_INVALID;
44 static const int BPROJ_TRIG;
45 static const int BPROJ_TABLE;
46 static const int BPROJ_DIFF;
47 static const int BPROJ_IDIFF;
49 static const int INTERP_INVALID;
50 static const int INTERP_NEAREST;
51 static const int INTERP_LINEAR;
52 static const int INTERP_CUBIC;
53 static const int INTERP_FREQ_PREINTERPOLATION;
54 #if HAVE_BSPLINE_INTERP
55 static const int INTERP_BSPLINE;
56 static const int INTERP_1BSPLINE;
57 static const int INTERP_2BSPLINE;
58 static const int INTERP_3BSPLINE;
61 Backprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
62 const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
66 void BackprojectView (const double* const viewData, const double viewAngle);
67 void PostProcessing();
69 bool fail() const {return m_fail;}
70 const std::string& failMessage() const {return m_failMessage;}
72 static const int getBackprojectCount() {return s_iBackprojectCount;}
73 static const char* const* getBackprojectNameArray() {return s_aszBackprojectName;}
74 static const char* const* getBackprojectTitleArray() {return s_aszBackprojectTitle;}
75 static int convertBackprojectNameToID (const char* const bprojName);
76 static const char* convertBackprojectIDToName (const int bprojID);
77 static const char* convertBackprojectIDToTitle (const int bprojID);
79 static const int getInterpCount() {return s_iInterpCount;}
80 static const char* const * getInterpNameArray() {return s_aszInterpName;}
81 static const char* const * getInterpTitleArray() {return s_aszInterpTitle;}
82 static int convertInterpNameToID (const char* const interpName);
83 static const char* convertInterpIDToName (const int interpID);
84 static const char* convertInterpIDToTitle (const int interpID);
88 std::string m_nameBackproject;
89 std::string m_nameInterpolation;
91 int m_idInterpolation;
92 Backproject* m_pBackprojectImplem;
94 std::string m_failMessage;
96 static const char* const s_aszBackprojectName[];
97 static const char* const s_aszBackprojectTitle[];
98 static const int s_iBackprojectCount;
100 static const char* const s_aszInterpName[];
101 static const char* const s_aszInterpTitle[];
102 static const int s_iInterpCount;
104 bool initBackprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
105 const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
112 Backproject (const Projections& proj, ImageFile& im, int interpID, const int interpFactor,
113 const ReconstructionROI* pROI);
115 virtual ~Backproject ();
117 virtual void BackprojectView (const double* const viewData, const double viewAngle) = 0;
118 virtual void PostProcessing (); // call after backprojecting all views
121 void ScaleImageByRotIncrement ();
122 void errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int ni);
123 void errorIndexOutsideDetector (int ix, int iy, double theta, double L, int ni);
124 const Projections& proj;
132 int iDetCenter; // index refering to L=0 projection
134 double xMin, xMax, yMin, yMax; // Retangular coords of phantom
135 double xInc, yInc; // size of cells
137 double m_dFocalLength;
138 double m_dSourceDetectorLength;
139 bool m_bPostProcessingDone;
142 Backproject (const Backproject& rhs);
143 Backproject& operator= (const Backproject& rhs);
147 class BackprojectTrig : public Backproject
150 BackprojectTrig (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
151 : Backproject (proj, im, interpID, interpFactor, pROI)
154 void BackprojectView (const double* const t, const double view_angle);
158 class BackprojectTable : public Backproject
161 BackprojectTable (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
162 virtual ~BackprojectTable ();
164 virtual void BackprojectView (const double* const t, const double view_angle);
165 virtual void PostProcessing (); // call after backprojecting all views
168 Array2d<kfloat64> arrayR;
169 Array2d<kfloat64> arrayPhi;
175 class BackprojectDiff : public Backproject
178 BackprojectDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
181 virtual void BackprojectView (const double* const t, const double view_angle);
182 virtual void PostProcessing (); // call after backprojecting all views
187 double im_xinc, im_yinc;
191 class BackprojectIntDiff : public BackprojectDiff
194 BackprojectIntDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
195 : BackprojectDiff (proj, im, interpID, interpFactor, pROI)
198 void BackprojectView (const double* const t, const double view_angle);
201 class BackprojectEquilinear : public BackprojectTable
204 BackprojectEquilinear (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
205 : BackprojectTable (proj, im, interpID, interpFactor, pROI)
208 void BackprojectView (const double* const t, const double view_angle);
210 virtual ~BackprojectEquilinear()
214 class BackprojectEquiangular : public BackprojectTable
217 BackprojectEquiangular (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
218 : BackprojectTable (proj, im, interpID, interpFactor, pROI)
221 void BackprojectView (const double* const t, const double view_angle);
223 virtual ~BackprojectEquiangular()