1 /*****************************************************************************
5 ** Purpose: Header file for Projections class
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 1, 1984
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: projections.h,v 1.23 2001/02/08 22:01:27 kevin Exp $
15 ** This program is free software; you can redistribute it and/or modify
16 ** it under the terms of the GNU General Public License (version 2) as
17 ** published by the Free Software Foundation.
19 ** This program is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ** GNU General Public License for more details.
24 ** You should have received a copy of the GNU General Public License
25 ** along with this program; if not, write to the Free Software
26 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 ******************************************************************************/
34 class Array2dFileLabel;
35 class fnetorderstream;
37 #include "array2dfile.h"
38 #include "imagefile.h"
46 static const int POLAR_INTERP_INVALID;
47 static const int POLAR_INTERP_NEAREST;
48 static const int POLAR_INTERP_BILINEAR;
49 static const int POLAR_INTERP_BICUBIC;
51 Projections (const int nView, const int nDet);
52 Projections (const Scanner& scanner);
56 static const int getInterpCount() {return s_iInterpCount;}
57 static const char** getInterpNameArray() {return s_aszInterpName;}
58 static const char** getInterpTitleArray() {return s_aszInterpTitle;}
59 static int convertInterpNameToID (const char* const interpName);
60 static const char* convertInterpIDToName (const int interpID);
61 static const char* convertInterpIDToTitle (const int interpID);
63 void initFromScanner (const Scanner& scanner);
65 void printProjectionData (int startView, int endView);
66 void printProjectionData ();
67 void printScanInfo (std::ostringstream& os) const;
69 bool read (const std::string& fname);
70 bool read (const char* fname);
71 bool write (const char* fname);
72 bool write (const std::string& fname);
73 bool detarrayRead (fnetorderstream& fs, DetectorArray& darray, const int view_num);
74 bool detarrayWrite (fnetorderstream& fs, const DetectorArray& darray, const int view_num);
76 bool convertPolar (ImageFile& rIF, int iInterpolation);
77 bool convertFFTPolar (ImageFile& rIF, int iInterpolation, int iZeropad);
78 void calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double** ppdView, double** ppdDet);
79 void interpolatePolar (ImageFileArray& v, ImageFileArray& vImag, unsigned int nx, unsigned int ny, std::complex<double>** ppcDetValue,
80 double** ppdDet, double** ppdView, unsigned int nView, unsigned int nDet, int iInterpolate);
82 bool reconstruct (ImageFile& im, const char* const filterName, double filt_param, const char* const filterMethodName, const int zeropad, const char* frequencyFilterName, const char* const interpName, int interp_param, const char* const backprojName, const int trace) const;
84 void setNView (int nView); // used in MPI to restrict # of views
85 void setRotInc (double rotInc) { m_rotInc = rotInc;}
86 void setDetInc (double detInc) { m_detInc = detInc;}
87 void setCalcTime (double calcTime) {m_calcTime = calcTime;}
88 void setRemark (const char* remark) {m_remark = remark; m_label.setLabelString(remark);}
89 void setRemark (const std::string& remark) {setRemark(remark.c_str());}
91 double detStart() const {return m_detStart;}
92 double rotStart() const {return m_rotStart;}
93 double calcTime() const {return m_calcTime;}
94 double viewLen() const {return m_dViewDiameter / SQRT2;}
95 const char* remark() const {return m_remark.c_str();}
96 double detInc() const {return m_detInc;}
97 double rotInc() const {return m_rotInc;}
98 int nDet() const {return m_nDet;}
99 int nView() const {return m_nView;}
100 int geometry() const {return m_geometry;}
101 double focalLength() const {return m_dFocalLength;}
102 double phmLen() const { return m_dViewDiameter / SQRT2; }
103 void setPhmLen(double phmLen) { m_dViewDiameter = phmLen * SQRT2; }
105 const std::string& getFilename() const {return m_filename;}
106 Array2dFileLabel& getLabel() {return m_label;}
107 const Array2dFileLabel& getLabel() const {return m_label;}
109 DetectorArray& getDetectorArray (const int iview)
110 { return (*m_projData[iview]); }
112 const DetectorArray& getDetectorArray (const int iview) const
113 { return (*m_projData[iview]); }
115 static bool copyHeader (const char* const filename, std::ostream& os);
116 static bool copyHeader (const std::string& filename, std::ostream& os);
118 static bool copyViewData (const char* const filename, std::ostream& os, int startView, int endView);
119 static bool copyViewData (const std::string& filename, std::ostream& os, int startView, int endView);
122 int m_headerSize; // Size of disk file header
123 int m_geometry; // Geometry of scanner
124 class DetectorArray **m_projData; // Pointer to array of detarray_st pointers
125 std::string m_remark; // description of raysum data
126 int m_nDet; // number of detectors in array
127 int m_nView; // number of rotated views
128 double m_calcTime; // time required to calculate raysums
129 double m_rotStart; // starting view rotation
130 double m_rotInc; // angle between rotations
131 double m_detStart; // distance of beginning detector to center phantom
132 double m_detInc; // increment between detectors
133 double m_dFocalLength;
134 double m_dViewDiameter;
135 double m_dFanBeamAngle;
136 kuint32 m_year; // Creation date & time
142 std::string m_filename;
143 Array2dFileLabel m_label;
145 const static kuint16 m_signature;
147 static const char* s_aszInterpName[];
148 static const char* s_aszInterpTitle[];
149 static const int s_iInterpCount;
151 bool headerWrite (fnetorderstream& fs);
152 bool headerRead (fnetorderstream& fs);
154 void deleteProjData ();
156 void init (const int nView, const int nDet);
158 // prevent default methods
159 Projections& operator= (const Projections& rhs); // assignment
160 Projections(const Projections& rhs); // copy