1 #ifndef CTL_BACKPROJECTORBASE_H 2 #define CTL_BACKPROJECTORBASE_H 5 #include "acquisition/acquisitionsetup.h" 6 #include "mat/matrix_types.h" 7 #include "ocl/pinnedmem.h" 11 class SingleViewGeometry;
95 using ProjectionWeights = std::vector<std::vector<
float>>;
96 enum class WeightingType { DistanceWeightsOnly, GeometryFactors };
125 const cl::CommandQueue&
queue()
const;
137 WeightingType _weightingType;
140 ProjectionWeights _precompGeomFactors;
143 ProjectionWeights _customWeights;
146 cl::CommandQueue _queue;
148 cl::Kernel* _kernelBacksmear;
149 cl::Kernel* _kernelNullifier;
152 cl::Buffer _volCornerBuffer;
153 cl::Buffer _voxSizeBuffer;
154 cl::Buffer _pMatBuffer;
155 cl::Buffer _sliceBuffer;
158 std::unique_ptr<PinnedImg3DHostWrite> _projBuf;
161 std::array<uint, 3> _nbVoxels{ 0, 0, 0 };
163 Vector3x1 _corner{ 0.0 };
164 cl::size_t<3> _zeroVec, _projBufferDim;
165 size_t _bytesLocPMatMem;
166 uint _nbModules, _viewsPerBlock;
175 void setDimensions(
const ProjectionData::Dimensions& projDim,
176 const VoxelVolume<float>& targetVolume);
188 const SingleViewGeometry& modPMats);
198 using BackprojectorWeighting = OCL::BackprojectorBase::WeightingType;
201 bool isConsistentPair(
const AcquisitionSetup& setup,
const ProjectionDataView& projections);
210 ret.reserve(static_cast<int>(vector.size()));
212 for(
const auto& val : vector)
227 ret.reserve(list.size());
229 for(
const auto& val : list)
230 ret.push_back(qvariant_cast<T>(val));
240 #endif // CTL_BACKPROJECTORBASE_H WeightingType weightingType() const
Returns the weighting type of this instance.
Definition: backprojectorbase.cpp:109
void transferProjectionData(const ProjectionDataView &projections, uint startView, uint nbViews)
Writes (non-blocking) projection data into the corresponding OpenCL buffer.
Definition: backprojectorbase.cpp:604
void readoutResult(VoxelVolume< float > &targetVolume, uint z)
Reads out the data current present in the slice buffer.
Definition: backprojectorbase.cpp:454
void setBacksmearKernel(cl::Kernel *backsmearKernel)
Sets the backprojection kernel to be used to backsmearKernel.
Definition: backprojectorbase.cpp:529
void createBuffers()
Creates OpenCL buffers for volume corner, voxel size, projection matrices and the slice data.
Definition: backprojectorbase.cpp:378
static std::vector< float > computeGeometryFactors(float volumeOfSingleVoxel, const SingleViewGeometry &modPMats)
Computes (and returns) geometry factors for all modules in modPMats.
Definition: backprojectorbase.cpp:694
void precomputeGeometryFactors(float volumeOfSingleVoxel, const FullGeometry &pMats)
Pre-computes geometry factors for all projection matrices in pMats.
Definition: backprojectorbase.cpp:713
bool isConfigConsistentWith(const ProjectionDataView &projections) const
Returns true if the currently configured setup is consistent with projections.
Definition: backprojectorbase.cpp:305
void createPinnedMemory()
Creates OpenCL 3D image (using pinned memory approach) for projection data.
Definition: backprojectorbase.cpp:394
void configure(const AcquisitionSetup &setup) override
Passes the AcquisitionSetup that describes the setting in which projections that shall be backproject...
Definition: backprojectorbase.cpp:59
void createCommandQueue()
Creates the OpenCL command queue.
Definition: backprojectorbase.cpp:363
Holds a CTSystem together with the information about the system settings for all views from which pro...
Definition: acquisitionsetup.h:175
The ProjectionDataView class is a read-only wrapper for a reference to ProjectionData.
Definition: projectiondataview.h:51
virtual void transferAdditionalData(uint startView, uint nbViews)
Placeholder method to be used to transfer data for processing of nbViews views beginning with startVi...
Definition: backprojectorbase.cpp:43
void transferSlice(const VoxelVolume< float > &targetVolume, uint z)
Writes (non-blocking) data of slice z from targetVolume into the corresponding OpenCL buffer.
Definition: backprojectorbase.cpp:590
void startBacksmearKernel(uint slice, uint view)
Sets the slice index and view id argument of the backprojection kernel and starts it.
Definition: backprojectorbase.cpp:537
static QMetaEnum metaEnum()
QMetaEnum object used to decode/encode subset order enum values.
Definition: backprojectorbase.cpp:682
The AbstractReconstructor class defined the interface for reconstruction types.
Definition: abstractreconstructor.h:163
virtual float weighting(uint view, uint module) const
Returns the weighting factor for data from detector module module in view view.
Definition: backprojectorbase.cpp:87
void setDimensions(const ProjectionData::Dimensions &projDim, const VoxelVolume< float > &targetVolume)
Sets all relevant dimension spec for this instance based on the projection dimensions projDim and the...
Definition: backprojectorbase.cpp:477
void setFixedKernelArgs()
Sets all fixed (i.e. contant for the entire backprojection operation) kernel arguments.
Definition: backprojectorbase.cpp:501
void transferProjectionMatrices(const float *src, uint startView, uint nbViews)
Writes (non-blocking) projection matrices into the corresponding OpenCL buffer.
Definition: backprojectorbase.cpp:579
void setCustomWeights(ProjectionWeights weights)
Sets custom weights to weights.
Definition: backprojectorbase.cpp:122
QVariantList vectorToVariantList(const std::vector< T > &vector)
Converts data from vector into a QVariantList.
Definition: backprojectorbase.h:207
void initNullifierKernel()
Initializes the OpenCL kernel that nullifies slice data.
Definition: backprojectorbase.cpp:418
void writeFixedBuffers()
Writes (blocking) all data into the fixed (i.e. contant for the entire backprojection operation) Open...
Definition: backprojectorbase.cpp:559
Struct that holds the dimensions of a ProjectionData object.
Definition: projectiondata.h:118
const AcquisitionSetup & setup() const
Returns a reference-to-const to the current AcquisitionSetup set via configure().
Definition: backprojectorbase.cpp:96
void startNullifierKernel()
Starts the nullifier kernel.
Definition: backprojectorbase.cpp:549
bool reconstructToPlain(const ProjectionDataView &projections, VoxelVolume< float > &targetVolume) override
Backprojects data from projections into targetVolume and returns true on success.
Definition: backprojectorbase.cpp:204
#define CTL_TYPE_ID(newIndex)
Definition: serializationinterface.h:189
void setParameter(const QVariant ¶meter) override
Sets the parameters of this instance based on the passed QVariant parameter.
Definition: backprojectorbase.cpp:164
unsigned int uint
Qt style alias for unsigned int.
Definition: modulelayout.h:6
void freeGPUMemory()
Cleans up the GPU memory allocated by createBuffers() and createPinnedMemory().
Definition: backprojectorbase.cpp:402
float precomputedGeometryFactor(uint view, uint module) const
Returns a (pre-computed) geometry factor for detector module module in view view.
Definition: backprojectorbase.cpp:727
cl::Kernel * backsmearKernel() const
Returns a pointer to the cl::Kernel object of this instances OpenCL backprojection kernel.
Definition: backprojectorbase.cpp:355
bool isConsistentPair(const AcquisitionSetup &setup, const ProjectionDataView &projections)
Returns true if the specifications in setup are consistent with projections.
Definition: backprojectorbase.cpp:749
static uint viewsPerBlock(const ProjectionData::Dimensions &projDim)
Computes how many views of data with dimensions given by projDim can be processed within one block (i...
Definition: backprojectorbase.cpp:639
The BackprojectorBase class is a helper class from which OpenCL implementations of cone-beam backproj...
Definition: backprojectorbase.h:86
bool customWeightsValid(const ProjectionDataView &projections) const
Returns true if the custom weights set to this instance are consistent with projections.
Definition: backprojectorbase.cpp:326
const cl::CommandQueue & queue() const
Returns a reference-to-const to the OpenCL command queue used by this instance.
Definition: backprojectorbase.cpp:104
QVariant parameter() const override
Returns the parameters of this instance as a QVariant.
Definition: backprojectorbase.cpp:135
void setWeightingType(WeightingType weigthType)
Sets the weighting type of this instance to weightType.
Definition: backprojectorbase.cpp:114
BackprojectorBase(cl::Kernel *backsmearKernel, WeightingType weightingType)
Constructs BackprojectorBase with the OpenCL kernel backsmearKernel using weighting defined by weight...
Definition: backprojectorbase.cpp:20
std::vector< T > variantListToVector(const QVariantList &list)
Converts data from list vector into an std::vector<T>.
Definition: backprojectorbase.h:224