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.25 2001/03/11 15:27:30 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"
40 struct ReconstructionROI;
45 static const int BPROJ_INVALID;
46 static const int BPROJ_TRIG;
47 static const int BPROJ_TABLE;
48 static const int BPROJ_DIFF;
49 static const int BPROJ_IDIFF;
51 static const int INTERP_INVALID;
52 static const int INTERP_NEAREST;
53 static const int INTERP_LINEAR;
54 static const int INTERP_CUBIC;
55 static const int INTERP_FREQ_PREINTERPOLATION;
56 #if HAVE_BSPLINE_INTERP
57 static const int INTERP_BSPLINE;
58 static const int INTERP_1BSPLINE;
59 static const int INTERP_2BSPLINE;
60 static const int INTERP_3BSPLINE;
63 Backprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
64 const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
68 void BackprojectView (const double* const viewData, const double viewAngle);
69 void PostProcessing();
71 bool fail() const {return m_fail;}
72 const std::string& failMessage() const {return m_failMessage;}
74 static const int getBackprojectCount() {return s_iBackprojectCount;}
75 static const char* const* getBackprojectNameArray() {return s_aszBackprojectName;}
76 static const char* const* getBackprojectTitleArray() {return s_aszBackprojectTitle;}
77 static int convertBackprojectNameToID (const char* const bprojName);
78 static const char* convertBackprojectIDToName (const int bprojID);
79 static const char* convertBackprojectIDToTitle (const int bprojID);
81 static const int getInterpCount() {return s_iInterpCount;}
82 static const char* const * getInterpNameArray() {return s_aszInterpName;}
83 static const char* const * getInterpTitleArray() {return s_aszInterpTitle;}
84 static int convertInterpNameToID (const char* const interpName);
85 static const char* convertInterpIDToName (const int interpID);
86 static const char* convertInterpIDToTitle (const int interpID);
90 std::string m_nameBackproject;
91 std::string m_nameInterpolation;
93 int m_idInterpolation;
94 Backproject* m_pBackprojectImplem;
96 std::string m_failMessage;
98 static const char* const s_aszBackprojectName[];
99 static const char* const s_aszBackprojectTitle[];
100 static const int s_iBackprojectCount;
102 static const char* const s_aszInterpName[];
103 static const char* const s_aszInterpTitle[];
104 static const int s_iInterpCount;
106 bool initBackprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
107 const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
114 Backproject (const Projections& proj, ImageFile& im, int interpID, const int interpFactor,
115 const ReconstructionROI* pROI);
117 virtual ~Backproject ();
119 virtual void BackprojectView (const double* const viewData, const double viewAngle) = 0;
120 virtual void PostProcessing (); // call after backprojecting all views
123 void ScaleImageByRotIncrement ();
124 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double r, double phi, double L, int ni);
125 void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int ni);
126 const Projections& proj;
134 int iDetCenter; // index refering to L=0 projection
136 double xMin, xMax, yMin, yMax; // Retangular coords of phantom
137 double xInc, yInc; // size of cells
139 double m_dFocalLength;
140 double m_dSourceDetectorLength;
141 bool m_bPostProcessingDone;
144 Backproject (const Backproject& rhs);
145 Backproject& operator= (const Backproject& rhs);
149 class BackprojectTrig : public Backproject
152 BackprojectTrig (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
153 : Backproject (proj, im, interpID, interpFactor, pROI)
156 void BackprojectView (const double* const t, const double view_angle);
160 class BackprojectTable : public Backproject
163 BackprojectTable (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
164 virtual ~BackprojectTable ();
166 virtual void BackprojectView (const double* const t, const double view_angle);
167 virtual void PostProcessing (); // call after backprojecting all views
170 Array2d<kfloat64> arrayR;
171 Array2d<kfloat64> arrayPhi;
177 class BackprojectDiff : public Backproject
180 BackprojectDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
183 virtual void BackprojectView (const double* const t, const double view_angle);
184 virtual void PostProcessing (); // call after backprojecting all views
189 double im_xinc, im_yinc;
193 class BackprojectIntDiff : public BackprojectDiff
196 BackprojectIntDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
197 : BackprojectDiff (proj, im, interpID, interpFactor, pROI)
200 void BackprojectView (const double* const t, const double view_angle);
203 class BackprojectEquilinear : public BackprojectTable
206 BackprojectEquilinear (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
207 : BackprojectTable (proj, im, interpID, interpFactor, pROI)
210 void BackprojectView (const double* const t, const double view_angle);
212 virtual ~BackprojectEquilinear()
216 class BackprojectEquiangular : public BackprojectTable
219 BackprojectEquiangular (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
220 : BackprojectTable (proj, im, interpID, interpFactor, pROI)
223 void BackprojectView (const double* const t, const double view_angle);
225 virtual ~BackprojectEquiangular()