Revert "Update package dependency from libwxgtk3.0-dev to libwxgtk3.0-gtk3-dev for...
[ctsim.git] / include / backprojectors.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **      Name:         backproject.h
5 **      Purpose:      Backprojection classes
6 **      Programmer:   Kevin Rosenberg
7 **      Date Started: June 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2009 Kevin Rosenberg
11 **
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.
15 **
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.
20 **
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 ******************************************************************************/
25
26
27 #ifndef __BACKPROJECTORS_H
28 #define __BACKPROJECTORS_H
29
30 #undef HAVE_BSPLINE_INTERP
31
32 #include "imagefile.h"
33
34
35 class Backproject;
36 class ImageFile;
37 class Projections;
38 struct ReconstructionROI;
39
40 class Backprojector
41 {
42  public:
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;
48
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;
59 #endif
60
61   Backprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
62     const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
63
64   ~Backprojector ();
65
66   void BackprojectView (const double* const viewData, const double viewAngle);
67   void PostProcessing();
68
69   bool fail() const {return m_fail;}
70   const std::string& failMessage() const {return m_failMessage;}
71
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);
78
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);
85
86
87  private:
88   std::string m_nameBackproject;
89   std::string m_nameInterpolation;
90   int m_idBackproject;
91   int m_idInterpolation;
92   Backproject* m_pBackprojectImplem;
93   bool m_fail;
94   std::string m_failMessage;
95
96   static const char* const s_aszBackprojectName[];
97   static const char* const s_aszBackprojectTitle[];
98   static const int s_iBackprojectCount;
99
100   static const char* const s_aszInterpName[];
101   static const char* const s_aszInterpTitle[];
102   static const int s_iInterpCount;
103
104   bool initBackprojector (const Projections& proj, ImageFile& im, const char* const backprojName,
105     const char* const interpName, const int interpFactor, const ReconstructionROI* pROI);
106 };
107
108
109 class Backproject
110 {
111  public:
112     Backproject (const Projections& proj, ImageFile& im, int interpID, const int interpFactor,
113       const ReconstructionROI* pROI);
114
115     virtual ~Backproject ();
116
117     virtual void BackprojectView (const double* const viewData, const double viewAngle) = 0;
118     virtual void PostProcessing (); // call after backprojecting all views
119
120  protected:
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;
125     ImageFile& im;
126     int interpType;
127     ImageFileArray v;
128     kint32 nx;
129     kint32 ny;
130     double detInc;
131     double rotScale;
132     int iDetCenter;             // index refering to L=0 projection
133     int nDet;
134     double xMin, xMax, yMin, yMax;     // Retangular coords of phantom
135     double xInc, yInc;  // size of cells
136     int m_interpFactor;
137     double m_dFocalLength;
138     double m_dSourceDetectorLength;
139     bool m_bPostProcessingDone;
140
141  private:
142     Backproject (const Backproject& rhs);
143     Backproject& operator= (const Backproject& rhs);
144 };
145
146
147 class BackprojectTrig : public Backproject
148 {
149  public:
150   BackprojectTrig (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
151       : Backproject (proj, im, interpID, interpFactor, pROI)
152       {}
153
154   void BackprojectView (const double* const t, const double view_angle);
155 };
156
157
158 class BackprojectTable : public Backproject
159 {
160  public:
161   BackprojectTable (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
162   virtual ~BackprojectTable ();
163
164   virtual void BackprojectView (const double* const t, const double view_angle);
165   virtual void PostProcessing (); // call after backprojecting all views
166
167  protected:
168   Array2d<kfloat64> arrayR;
169   Array2d<kfloat64> arrayPhi;
170   kfloat64** r;
171   kfloat64** phi;
172 };
173
174
175 class BackprojectDiff : public Backproject
176 {
177  public:
178   BackprojectDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI);
179   ~BackprojectDiff ();
180
181   virtual void BackprojectView (const double* const t, const double view_angle);
182   virtual void PostProcessing (); // call after backprojecting all views
183
184  protected:
185   double start_r;
186   double start_phi;
187   double im_xinc, im_yinc;
188 };
189
190
191 class BackprojectIntDiff : public BackprojectDiff
192 {
193  public:
194   BackprojectIntDiff (const Projections& proj, ImageFile& im, int interpID, const int interpFactor, const ReconstructionROI* pROI)
195     :  BackprojectDiff (proj, im, interpID, interpFactor, pROI)
196     {}
197
198   void BackprojectView (const double* const t, const double view_angle);
199 };
200
201 class BackprojectEquilinear : public BackprojectTable
202 {
203  public:
204   BackprojectEquilinear (const Projections& proj, ImageFile& im, int interpID, const int interpFactor,  const ReconstructionROI* pROI)
205       : BackprojectTable (proj, im, interpID, interpFactor, pROI)
206       {}
207
208   void BackprojectView (const double* const t, const double view_angle);
209
210   virtual ~BackprojectEquilinear()
211       {}
212 };
213
214 class BackprojectEquiangular : public BackprojectTable
215 {
216  public:
217   BackprojectEquiangular (const Projections& proj, ImageFile& im, int interpID, const int interpFactor,  const ReconstructionROI* pROI)
218       : BackprojectTable (proj, im, interpID, interpFactor, pROI)
219       {}
220
221   void BackprojectView (const double* const t, const double view_angle);
222
223   virtual ~BackprojectEquiangular()
224       {}
225 };
226
227
228 #endif