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.27 2001/03/02 02:08:14 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* const* getInterpNameArray() {return s_aszInterpName;}
58 static const char* const* 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);
64 bool initFromSomatomAR_STAR (int iNViews, int iNDets, unsigned char* pData, unsigned long lDataLength);
66 void printProjectionData (int startView, int endView);
67 void printProjectionData ();
68 void printScanInfo (std::ostringstream& os) const;
70 bool read (const std::string& fname);
71 bool read (const char* fname);
72 bool write (const char* fname);
73 bool write (const std::string& fname);
74 bool detarrayRead (fnetorderstream& fs, DetectorArray& darray, const int view_num);
75 bool detarrayWrite (fnetorderstream& fs, const DetectorArray& darray, const int view_num);
77 bool convertPolar (ImageFile& rIF, int iInterpolation);
78 bool convertFFTPolar (ImageFile& rIF, int iInterpolation, int iZeropad);
79 bool calcArrayPolarCoordinates (unsigned int nx, unsigned int ny, double** ppdView, double** ppdDet);
80 void interpolatePolar (ImageFileArray& v, ImageFileArray& vImag, unsigned int nx, unsigned int ny, std::complex<double>** ppcDetValue,
81 double** ppdDet, double** ppdView, unsigned int nView, unsigned int nDet, int iInterpolate);
83 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;
85 void setNView (int nView); // used in MPI to restrict # of views
86 void setRotInc (double rotInc) { m_rotInc = rotInc;}
87 void setDetInc (double detInc) { m_detInc = detInc;}
88 void setCalcTime (double calcTime) {m_calcTime = calcTime;}
89 void setRemark (const char* remark) {m_remark = remark; m_label.setLabelString(remark);}
90 void setRemark (const std::string& remark) {setRemark(remark.c_str());}
92 double detStart() const {return m_detStart;}
93 double rotStart() const {return m_rotStart;}
94 double calcTime() const {return m_calcTime;}
95 double viewLen() const {return m_dViewDiameter / SQRT2;}
96 const char* remark() const {return m_remark.c_str();}
97 double detInc() const {return m_detInc;}
98 double rotInc() const {return m_rotInc;}
99 int nDet() const {return m_nDet;}
100 int nView() const {return m_nView;}
101 int geometry() const {return m_geometry;}
102 double focalLength() const {return m_dFocalLength;}
103 double sourceDetectorLength() const { return m_dSourceDetectorLength;}
105 double phmLen() const { return m_dViewDiameter / SQRT2; }
106 void setPhmLen(double phmLen) { m_dViewDiameter = phmLen * SQRT2; }
108 const std::string& getFilename() const {return m_filename;}
109 Array2dFileLabel& getLabel() {return m_label;}
110 const Array2dFileLabel& getLabel() const {return m_label;}
112 DetectorArray& getDetectorArray (const int iview)
113 { return (*m_projData[iview]); }
115 const DetectorArray& getDetectorArray (const int iview) const
116 { return (*m_projData[iview]); }
118 static bool copyHeader (const char* const filename, std::ostream& os);
119 static bool copyHeader (const std::string& filename, std::ostream& os);
121 static bool copyViewData (const char* const filename, std::ostream& os, int startView, int endView);
122 static bool copyViewData (const std::string& filename, std::ostream& os, int startView, int endView);
125 int m_headerSize; // Size of disk file header
126 int m_geometry; // Geometry of scanner
127 class DetectorArray **m_projData; // Pointer to array of detarray_st pointers
128 std::string m_remark; // description of raysum data
129 int m_nDet; // number of detectors in array
130 int m_nView; // number of rotated views
131 double m_calcTime; // time required to calculate raysums
132 double m_rotStart; // starting view rotation
133 double m_rotInc; // angle between rotations
134 double m_detStart; // distance of beginning detector to center phantom
135 double m_detInc; // increment between detectors
136 double m_dFocalLength;
137 double m_dSourceDetectorLength;
138 double m_dViewDiameter;
139 double m_dFanBeamAngle;
140 kuint32 m_year; // Creation date & time
146 std::string m_filename;
147 Array2dFileLabel m_label;
149 const static kuint16 m_signature;
151 static const char* const s_aszInterpName[];
152 static const char* const s_aszInterpTitle[];
153 static const int s_iInterpCount;
155 bool headerWrite (fnetorderstream& fs);
156 bool headerRead (fnetorderstream& fs);
158 void deleteProjData ();
160 void init (const int nView, const int nDet);
162 // prevent default methods
163 Projections& operator= (const Projections& rhs); // assignment
164 Projections(const Projections& rhs); // copy