1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/*
-----------------------------------------------------------------------
Copyright: 2010-2018, iMinds-Vision Lab, University of Antwerp
2014-2018, CWI, Amsterdam
Contact: astra@astra-toolbox.com
Website: http://www.astra-toolbox.com/
This file is part of the ASTRA Toolbox.
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The ASTRA Toolbox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
*/
#include "astra/FanFlatBeamLineKernelProjector2D.h"
#include <cmath>
#include <cstring>
#include <algorithm>
#include "astra/DataProjectorPolicies.h"
using namespace std;
using namespace astra;
#include "astra/FanFlatBeamLineKernelProjector2D.inl"
// type of the projector, needed to register with CProjectorFactory
std::string CFanFlatBeamLineKernelProjector2D::type = "line_fanflat";
//----------------------------------------------------------------------------------------
// default constructor
CFanFlatBeamLineKernelProjector2D::CFanFlatBeamLineKernelProjector2D()
{
_clear();
}
//----------------------------------------------------------------------------------------
// constructor
CFanFlatBeamLineKernelProjector2D::CFanFlatBeamLineKernelProjector2D(CFanFlatProjectionGeometry2D* _pProjectionGeometry,
CVolumeGeometry2D* _pReconstructionGeometry)
{
_clear();
initialize(_pProjectionGeometry, _pReconstructionGeometry);
}
//----------------------------------------------------------------------------------------
// destructor
CFanFlatBeamLineKernelProjector2D::~CFanFlatBeamLineKernelProjector2D()
{
clear();
}
//---------------------------------------------------------------------------------------
// Clear - Constructors
void CFanFlatBeamLineKernelProjector2D::_clear()
{
CProjector2D::_clear();
m_bIsInitialized = false;
}
//---------------------------------------------------------------------------------------
// Clear - Public
void CFanFlatBeamLineKernelProjector2D::clear()
{
CProjector2D::clear();
m_bIsInitialized = false;
}
//---------------------------------------------------------------------------------------
// Check
bool CFanFlatBeamLineKernelProjector2D::_check()
{
// check base class
ASTRA_CONFIG_CHECK(CProjector2D::_check(), "FanFlatBeamLineKernelProjector2D", "Error in Projector2D initialization");
ASTRA_CONFIG_CHECK(dynamic_cast<CFanFlatProjectionGeometry2D*>(m_pProjectionGeometry) || dynamic_cast<CFanFlatVecProjectionGeometry2D*>(m_pProjectionGeometry), "FanFlatBeamLineKernelProjector2D", "Unsupported projection geometry");
ASTRA_CONFIG_CHECK(abs(m_pVolumeGeometry->getPixelLengthX() / m_pVolumeGeometry->getPixelLengthY()) - 1 < eps, "FanFlatBeamLineKernelProjector2D", "Pixel height must equal pixel width.");
// success
return true;
}
//---------------------------------------------------------------------------------------
// Initialize, use a Config object
bool CFanFlatBeamLineKernelProjector2D::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
// if already initialized, clear first
if (m_bIsInitialized) {
clear();
}
// initialization of parent class
if (!CProjector2D::initialize(_cfg)) {
return false;
}
// success
m_bIsInitialized = _check();
return m_bIsInitialized;
}
//---------------------------------------------------------------------------------------
// Initialize
bool CFanFlatBeamLineKernelProjector2D::initialize(CFanFlatProjectionGeometry2D* _pProjectionGeometry,
CVolumeGeometry2D* _pVolumeGeometry)
{
// if already initialized, clear first
if (m_bIsInitialized) {
clear();
}
// hardcopy geometries
m_pProjectionGeometry = _pProjectionGeometry->clone();
m_pVolumeGeometry = _pVolumeGeometry->clone();
// success
m_bIsInitialized = _check();
return m_bIsInitialized;
}
//----------------------------------------------------------------------------------------
// Get maximum amount of weights on a single ray
int CFanFlatBeamLineKernelProjector2D::getProjectionWeightsCount(int _iProjectionIndex)
{
int maxDim = max(m_pVolumeGeometry->getGridRowCount(), m_pVolumeGeometry->getGridColCount());
return maxDim * 2 + 1;
}
//----------------------------------------------------------------------------------------
// Single Ray Weights
void CFanFlatBeamLineKernelProjector2D::computeSingleRayWeights(int _iProjectionIndex,
int _iDetectorIndex,
SPixelWeight* _pWeightedPixels,
int _iMaxPixelCount,
int& _iStoredPixelCount)
{
ASTRA_ASSERT(m_bIsInitialized);
StorePixelWeightsPolicy p(_pWeightedPixels, _iMaxPixelCount);
projectSingleRay(_iProjectionIndex, _iDetectorIndex, p);
_iStoredPixelCount = p.getStoredPixelCount();
}
//----------------------------------------------------------------------------------------
// Splat a single point
std::vector<SDetector2D> CFanFlatBeamLineKernelProjector2D::projectPoint(int _iRow, int _iCol)
{
std::vector<SDetector2D> res;
return res;
}
//----------------------------------------------------------------------------------------
//Result is always in [-PI/2; PI/2]
float32 CFanFlatBeamLineKernelProjector2D::angleBetweenVectors(float32 _fAX, float32 _fAY, float32 _fBX, float32 _fBY)
{
float32 sinAB = (_fAX*_fBY - _fAY*_fBX)/sqrt((_fAX*_fAX + _fAY*_fAY)*(_fBX*_fBX + _fBY*_fBY));
return asin(sinAB);
}
//----------------------------------------------------------------------------------------
|