From e5b70e8b53e4ecc81b1aacc3af7893faf49ddc24 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 22 Jun 2018 15:46:11 +0200 Subject: Move CUDA include files --- build/linux/Makefile.in | 4 +- cuda/2d/algo.cu | 18 +- cuda/2d/algo.h | 173 ------------ cuda/2d/arith.cu | 5 +- cuda/2d/arith.h | 85 ------ cuda/2d/astra.cu | 42 ++- cuda/2d/astra.h | 127 --------- cuda/2d/cgls.cu | 12 +- cuda/2d/cgls.h | 90 ------ cuda/2d/darthelper.cu | 5 +- cuda/2d/darthelper.h | 41 --- cuda/2d/dims.h | 68 ----- cuda/2d/em.cu | 12 +- cuda/2d/em.h | 75 ----- cuda/2d/fan_bp.cu | 12 +- cuda/2d/fan_bp.h | 52 ---- cuda/2d/fan_fp.cu | 14 +- cuda/2d/fan_fp.h | 40 --- cuda/2d/fbp.cu | 12 +- cuda/2d/fbp.h | 97 ------- cuda/2d/fbp_filters.h | 61 ---- cuda/2d/fft.cu | 14 +- cuda/2d/fft.h | 72 ----- cuda/2d/par_bp.cu | 12 +- cuda/2d/par_bp.h | 47 --- cuda/2d/par_fp.cu | 17 +- cuda/2d/par_fp.h | 40 --- cuda/2d/sart.cu | 16 +- cuda/2d/sart.h | 87 ------ cuda/2d/sirt.cu | 12 +- cuda/2d/sirt.h | 96 ------- cuda/2d/util.cu | 7 +- cuda/2d/util.h | 84 ------ cuda/3d/algo3d.cu | 12 +- cuda/3d/algo3d.h | 71 ----- cuda/3d/arith3d.cu | 5 +- cuda/3d/arith3d.h | 79 ------ cuda/3d/astra3d.cu | 25 +- cuda/3d/astra3d.h | 314 --------------------- cuda/3d/cgls3d.cu | 10 +- cuda/3d/cgls3d.h | 112 -------- cuda/3d/cone_bp.cu | 16 +- cuda/3d/cone_bp.h | 45 --- cuda/3d/cone_fp.cu | 14 +- cuda/3d/cone_fp.h | 45 --- cuda/3d/darthelper3d.cu | 7 +- cuda/3d/darthelper3d.h | 42 --- cuda/3d/dims3d.h | 77 ----- cuda/3d/fdk.cu | 25 +- cuda/3d/fdk.h | 50 ---- cuda/3d/mem3d.cu | 25 +- cuda/3d/mem3d.h | 105 ------- cuda/3d/par3d_bp.cu | 16 +- cuda/3d/par3d_bp.h | 46 --- cuda/3d/par3d_fp.cu | 15 +- cuda/3d/par3d_fp.h | 50 ---- cuda/3d/sirt3d.cu | 14 +- cuda/3d/sirt3d.h | 121 -------- cuda/3d/util3d.cu | 10 +- cuda/3d/util3d.h | 68 ----- .../astra/CudaFilteredBackProjectionAlgorithm.h | 8 +- include/astra/CudaProjector2D.h | 2 +- include/astra/CudaProjector3D.h | 2 +- include/astra/Float32Data3D.h | 2 +- include/astra/Float32Data3DGPU.h | 2 +- include/astra/cuda/2d/algo.h | 173 ++++++++++++ include/astra/cuda/2d/arith.h | 85 ++++++ include/astra/cuda/2d/astra.h | 127 +++++++++ include/astra/cuda/2d/cgls.h | 90 ++++++ include/astra/cuda/2d/darthelper.h | 41 +++ include/astra/cuda/2d/dims.h | 68 +++++ include/astra/cuda/2d/em.h | 75 +++++ include/astra/cuda/2d/fan_bp.h | 52 ++++ include/astra/cuda/2d/fan_fp.h | 40 +++ include/astra/cuda/2d/fbp.h | 97 +++++++ include/astra/cuda/2d/fbp_filters.h | 61 ++++ include/astra/cuda/2d/fft.h | 72 +++++ include/astra/cuda/2d/par_bp.h | 47 +++ include/astra/cuda/2d/par_fp.h | 40 +++ include/astra/cuda/2d/sart.h | 87 ++++++ include/astra/cuda/2d/sirt.h | 96 +++++++ include/astra/cuda/2d/util.h | 84 ++++++ include/astra/cuda/3d/algo3d.h | 71 +++++ include/astra/cuda/3d/arith3d.h | 79 ++++++ include/astra/cuda/3d/astra3d.h | 314 +++++++++++++++++++++ include/astra/cuda/3d/cgls3d.h | 112 ++++++++ include/astra/cuda/3d/cone_bp.h | 45 +++ include/astra/cuda/3d/cone_fp.h | 45 +++ include/astra/cuda/3d/darthelper3d.h | 42 +++ include/astra/cuda/3d/dims3d.h | 77 +++++ include/astra/cuda/3d/fdk.h | 50 ++++ include/astra/cuda/3d/mem3d.h | 105 +++++++ include/astra/cuda/3d/par3d_bp.h | 46 +++ include/astra/cuda/3d/par3d_fp.h | 50 ++++ include/astra/cuda/3d/sirt3d.h | 121 ++++++++ include/astra/cuda/3d/util3d.h | 68 +++++ matlab/mex/astra_mex_c.cpp | 4 +- python/astra/astra_c.pyx | 2 +- src/CompositeGeometryManager.cpp | 4 +- src/CudaBackProjectionAlgorithm.cpp | 2 +- src/CudaBackProjectionAlgorithm3D.cpp | 2 +- src/CudaCglsAlgorithm.cpp | 2 +- src/CudaCglsAlgorithm3D.cpp | 2 +- src/CudaDartMaskAlgorithm.cpp | 6 +- src/CudaDartMaskAlgorithm3D.cpp | 4 +- src/CudaDartSmoothingAlgorithm.cpp | 6 +- src/CudaDartSmoothingAlgorithm3D.cpp | 4 +- src/CudaDataOperationAlgorithm.cpp | 8 +- src/CudaEMAlgorithm.cpp | 2 +- src/CudaFDKAlgorithm3D.cpp | 6 +- src/CudaFilteredBackProjectionAlgorithm.cpp | 4 +- src/CudaForwardProjectionAlgorithm.cpp | 2 +- src/CudaForwardProjectionAlgorithm3D.cpp | 2 +- src/CudaReconstructionAlgorithm2D.cpp | 2 +- src/CudaRoiSelectAlgorithm.cpp | 6 +- src/CudaSartAlgorithm.cpp | 2 +- src/CudaSirtAlgorithm.cpp | 2 +- src/CudaSirtAlgorithm3D.cpp | 2 +- src/Float32Data3D.cpp | 2 +- src/Globals.cpp | 2 +- 120 files changed, 2812 insertions(+), 2812 deletions(-) delete mode 100644 cuda/2d/algo.h delete mode 100644 cuda/2d/arith.h delete mode 100644 cuda/2d/astra.h delete mode 100644 cuda/2d/cgls.h delete mode 100644 cuda/2d/darthelper.h delete mode 100644 cuda/2d/dims.h delete mode 100644 cuda/2d/em.h delete mode 100644 cuda/2d/fan_bp.h delete mode 100644 cuda/2d/fan_fp.h delete mode 100644 cuda/2d/fbp.h delete mode 100644 cuda/2d/fbp_filters.h delete mode 100644 cuda/2d/fft.h delete mode 100644 cuda/2d/par_bp.h delete mode 100644 cuda/2d/par_fp.h delete mode 100644 cuda/2d/sart.h delete mode 100644 cuda/2d/sirt.h delete mode 100644 cuda/2d/util.h delete mode 100644 cuda/3d/algo3d.h delete mode 100644 cuda/3d/arith3d.h delete mode 100644 cuda/3d/astra3d.h delete mode 100644 cuda/3d/cgls3d.h delete mode 100644 cuda/3d/cone_bp.h delete mode 100644 cuda/3d/cone_fp.h delete mode 100644 cuda/3d/darthelper3d.h delete mode 100644 cuda/3d/dims3d.h delete mode 100644 cuda/3d/fdk.h delete mode 100644 cuda/3d/mem3d.h delete mode 100644 cuda/3d/par3d_bp.h delete mode 100644 cuda/3d/par3d_fp.h delete mode 100644 cuda/3d/sirt3d.h delete mode 100644 cuda/3d/util3d.h create mode 100644 include/astra/cuda/2d/algo.h create mode 100644 include/astra/cuda/2d/arith.h create mode 100644 include/astra/cuda/2d/astra.h create mode 100644 include/astra/cuda/2d/cgls.h create mode 100644 include/astra/cuda/2d/darthelper.h create mode 100644 include/astra/cuda/2d/dims.h create mode 100644 include/astra/cuda/2d/em.h create mode 100644 include/astra/cuda/2d/fan_bp.h create mode 100644 include/astra/cuda/2d/fan_fp.h create mode 100644 include/astra/cuda/2d/fbp.h create mode 100644 include/astra/cuda/2d/fbp_filters.h create mode 100644 include/astra/cuda/2d/fft.h create mode 100644 include/astra/cuda/2d/par_bp.h create mode 100644 include/astra/cuda/2d/par_fp.h create mode 100644 include/astra/cuda/2d/sart.h create mode 100644 include/astra/cuda/2d/sirt.h create mode 100644 include/astra/cuda/2d/util.h create mode 100644 include/astra/cuda/3d/algo3d.h create mode 100644 include/astra/cuda/3d/arith3d.h create mode 100644 include/astra/cuda/3d/astra3d.h create mode 100644 include/astra/cuda/3d/cgls3d.h create mode 100644 include/astra/cuda/3d/cone_bp.h create mode 100644 include/astra/cuda/3d/cone_fp.h create mode 100644 include/astra/cuda/3d/darthelper3d.h create mode 100644 include/astra/cuda/3d/dims3d.h create mode 100644 include/astra/cuda/3d/fdk.h create mode 100644 include/astra/cuda/3d/mem3d.h create mode 100644 include/astra/cuda/3d/par3d_bp.h create mode 100644 include/astra/cuda/3d/par3d_fp.h create mode 100644 include/astra/cuda/3d/sirt3d.h create mode 100644 include/astra/cuda/3d/util3d.h diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 77e89e7..1627a2e 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -57,7 +57,7 @@ BOOSTUTF_LIBS=@LIBS_BOOSTUTF@ ifeq ($(cuda),yes) CPPFLAGS += @CPPFLAGS_CUDA@ -DASTRA_CUDA -NVCCFLAGS += @NVCCFLAGS_EXTRA@ @CPPFLAGS_CUDA@ -I$(srcdir)/../.. -I$(srcdir)/../../include -DASTRA_CUDA +NVCCFLAGS += @NVCCFLAGS_EXTRA@ @CPPFLAGS_CUDA@ -I$(srcdir)/../../include -DASTRA_CUDA LDFLAGS += @LDFLAGS_CUDA@ LIBS += -lcudart -lcufft NVCC = @NVCC@ @@ -91,7 +91,7 @@ endif # This is below where PYCPPFLAGS copies CPPFLAGS. The python code is built # from a different directory, so these relative includes would be wrong. -CPPFLAGS+=-I$(srcdir)/../.. -I$(srcdir)/../../include -I$(srcdir)/../../lib/include +CPPFLAGS+=-I$(srcdir)/../../include -I$(srcdir)/../../lib/include ifeq ($(matlab),yes) MEXFLAGS = -cxx diff --git a/cuda/2d/algo.cu b/cuda/2d/algo.cu index 02790f0..f809c23 100644 --- a/cuda/2d/algo.cu +++ b/cuda/2d/algo.cu @@ -25,16 +25,16 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include +#include "astra/cuda/2d/algo.h" +#include "astra/cuda/2d/par_fp.h" +#include "astra/cuda/2d/fan_fp.h" +#include "astra/cuda/2d/par_bp.h" +#include "astra/cuda/2d/fan_bp.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" +#include "astra/cuda/2d/astra.h" -#include "algo.h" -#include "par_fp.h" -#include "fan_fp.h" -#include "par_bp.h" -#include "fan_bp.h" -#include "util.h" -#include "arith.h" -#include "astra.h" +#include namespace astraCUDA { diff --git a/cuda/2d/algo.h b/cuda/2d/algo.h deleted file mode 100644 index 2ce929c..0000000 --- a/cuda/2d/algo.h +++ /dev/null @@ -1,173 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ALGO_H -#define _CUDA_ALGO_H - -#include "astra/Globals.h" -#include "dims.h" - -namespace astra { - -class CParallelProjectionGeometry2D; -class CParallelVecProjectionGeometry2D; -class CFanFlatProjectionGeometry2D; -class CFanFlatVecProjectionGeometry2D; -class CVolumeGeometry2D; -class CProjectionGeometry2D; - -} - -namespace astraCUDA { - -class _AstraExport ReconAlgo { -public: - ReconAlgo(); - virtual ~ReconAlgo(); - - bool setGPUIndex(int iGPUIndex); - - bool setGeometry(const astra::CVolumeGeometry2D* pVolGeom, - const astra::CProjectionGeometry2D* pProjGeom); - - bool setSuperSampling(int raysPerDet, int raysPerPixelDim); - - void signalAbort() { shouldAbort = true; } - - virtual bool enableVolumeMask(); - virtual bool enableSinogramMask(); - - // init should be called after setting all geometry - virtual bool init() = 0; - - // setVolumeMask should be called after init and before iterate, - // but only if enableVolumeMask was called before init. - // It may be called again after iterate. - bool setVolumeMask(float* D_maskData, unsigned int maskPitch); - - // setSinogramMask should be called after init and before iterate, - // but only if enableSinogramMask was called before init. - // It may be called again after iterate. - bool setSinogramMask(float* D_smaskData, unsigned int smaskPitch); - - - // setBuffers should be called after init and before iterate. - // It may be called again after iterate. - virtual bool setBuffers(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch); - - - // instead of calling setBuffers, you can also call allocateBuffers - // to let ReconAlgo manage its own GPU memory - virtual bool allocateBuffers(); - - // copy data to GPU. This must be called after allocateBuffers. - // pfSinogram, pfReconstruction, pfVolMask, pfSinoMask are the - // sinogram, reconstruction, volume mask and sinogram mask in system RAM, - // respectively. The corresponding pitch variables give the pitches - // of these buffers, measured in floats. - // The sinogram is multiplied by fSinogramScale after uploading it. - virtual bool copyDataToGPU(const float* pfSinogram, unsigned int iSinogramPitch, float fSinogramScale, - const float* pfReconstruction, unsigned int iReconstructionPitch, - const float* pfVolMask, unsigned int iVolMaskPitch, - const float* pfSinoMask, unsigned int iSinoMaskPitch); - - - - // set Min/Max constraints. They may be called at any time, and will affect - // any iterate() calls afterwards. - virtual bool setMinConstraint(float fMin); - virtual bool setMaxConstraint(float fMax); - - - // iterate should be called after init and setBuffers. - // It may be called multiple times. - virtual bool iterate(unsigned int iterations) = 0; - - // Compute the norm of the difference of the FP of the current - // reconstruction and the sinogram. (This performs one FP.) - // It can be called after iterate. - virtual float computeDiffNorm() = 0; - // TODO: computeDiffNorm shouldn't be virtual, but for it to be - // implemented in ReconAlgo, it needs a way to get a suitable - // temporary sinogram buffer. - - bool getReconstruction(float* pfReconstruction, - unsigned int iReconstructionPitch) const; - - - -protected: - void reset(); - - bool callFP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - float outputScale); - bool callBP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - float outputScale); - - - SDimensions dims; - SParProjection* parProjs; - SFanProjection* fanProjs; - float fOutputScale; - - volatile bool shouldAbort; - - bool freeGPUMemory; - - // Input/output - float* D_sinoData; - unsigned int sinoPitch; - - float* D_volumeData; - unsigned int volumePitch; - - // Masks - bool useVolumeMask; - bool useSinogramMask; - - float* D_maskData; - unsigned int maskPitch; - float* D_smaskData; - unsigned int smaskPitch; - - // Min/max - bool useMinConstraint; - bool useMaxConstraint; - float fMinConstraint; - float fMaxConstraint; - - -}; - - -} - -#endif - diff --git a/cuda/2d/arith.cu b/cuda/2d/arith.cu index 0ff4aa0..62eb8c2 100644 --- a/cuda/2d/arith.cu +++ b/cuda/2d/arith.cu @@ -25,8 +25,9 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" + #include namespace astraCUDA { diff --git a/cuda/2d/arith.h b/cuda/2d/arith.h deleted file mode 100644 index e18bb1b..0000000 --- a/cuda/2d/arith.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ARITH_H -#define _CUDA_ARITH_H - -#include - -namespace astraCUDA { - - -struct opAddScaled; -struct opScaleAndAdd; -struct opAddMulScaled; -struct opAddMul; -struct opAdd; -struct opAdd2; -struct opMul; -struct opDiv; -struct opMul2; -struct opDividedBy; -struct opInvert; -struct opSet; -struct opClampMin; -struct opClampMax; -struct opClampMinMask; -struct opClampMaxMask; -struct opSegmentAndMask; -struct opSetMaskedValues; - -struct opMulMask; - - -template void processVolCopy(float* out, const SDimensions& dims); -template void processVolCopy(float* out, float param, const SDimensions& dims); -template void processVolCopy(float* out1, float* out2, float param1, float param2, const SDimensions& dims); -template void processVolCopy(float* out, const float* in, const SDimensions& dims); -template void processVolCopy(float* out, const float* in, float param, const SDimensions& dims); -template void processVolCopy(float* out, const float* in1, const float* in2, const SDimensions& dims); -template void processVolCopy(float* out, const float* in1, const float* in2, float param, const SDimensions& dims); - -template void processVol(float* out, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out, float fParam, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out1, float* out2, float fParam1, float fParam2, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out, const float* in, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out, const float* in, float fParam, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out, const float* in1, const float* in2, float fParam, unsigned int pitch, const SDimensions& dims); -template void processVol(float* out, const float* in1, const float* in2, unsigned int pitch, const SDimensions& dims); - -template void processSino(float* out, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out, float fParam, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out1, float* out2, float fParam1, float fParam2, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out, const float* in, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out, const float* in, float fParam, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out, const float* in1, const float* in2, float fParam, unsigned int pitch, const SDimensions& dims); -template void processSino(float* out, const float* in1, const float* in2, unsigned int pitch, const SDimensions& dims); - - -} - -#endif diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 2ee469c..ec03517 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -25,33 +25,31 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/par_fp.h" +#include "astra/cuda/2d/fan_fp.h" +#include "astra/cuda/2d/par_bp.h" +#include "astra/cuda/2d/fan_bp.h" +#include "astra/cuda/2d/arith.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/fft.h" -#include "util.h" -#include "par_fp.h" -#include "fan_fp.h" -#include "par_bp.h" -#include "fan_bp.h" -#include "arith.h" -#include "astra.h" +// For fan beam FBP weighting +#include "astra/cuda/3d/fdk.h" -#include "fft.h" +#include "astra/GeometryUtil2D.h" +#include "astra/VolumeGeometry2D.h" +#include "astra/ParallelProjectionGeometry2D.h" +#include "astra/ParallelVecProjectionGeometry2D.h" +#include "astra/FanFlatProjectionGeometry2D.h" +#include "astra/FanFlatVecProjectionGeometry2D.h" +#include "astra/Logging.h" +#include +#include #include -#include - -#include "../../include/astra/GeometryUtil2D.h" -#include "../../include/astra/VolumeGeometry2D.h" -#include "../../include/astra/ParallelProjectionGeometry2D.h" -#include "../../include/astra/ParallelVecProjectionGeometry2D.h" -#include "../../include/astra/FanFlatProjectionGeometry2D.h" -#include "../../include/astra/FanFlatVecProjectionGeometry2D.h" - -#include "../../include/astra/Logging.h" -// For fan beam FBP weighting -#include "../3d/fdk.h" +#include using namespace astraCUDA; using namespace std; diff --git a/cuda/2d/astra.h b/cuda/2d/astra.h deleted file mode 100644 index 6f0e2f0..0000000 --- a/cuda/2d/astra.h +++ /dev/null @@ -1,127 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ASTRA_H -#define _CUDA_ASTRA_H - -#include "fbp_filters.h" -#include "dims.h" -#include "algo.h" - -using astraCUDA::SFanProjection; - -namespace astra { - -enum Cuda2DProjectionKernel { - ker2d_default = 0 -}; - -class CParallelProjectionGeometry2D; -class CParallelVecProjectionGeometry2D; -class CFanFlatProjectionGeometry2D; -class CFanFlatVecProjectionGeometry2D; -class CVolumeGeometry2D; -class CProjectionGeometry2D; - - -class _AstraExport BPalgo : public astraCUDA::ReconAlgo { -public: - BPalgo(); - ~BPalgo(); - - virtual bool init(); - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm(); -}; - - - - -// TODO: Clean up this interface to FP - -// Do a single forward projection -_AstraExport bool astraCudaFP(const float* pfVolume, float* pfSinogram, - unsigned int iVolWidth, unsigned int iVolHeight, - unsigned int iProjAngles, unsigned int iProjDets, - const SParProjection *pAngles, - unsigned int iDetSuperSampling = 1, - float fOutputScale = 1.0f, int iGPUIndex = 0); - -_AstraExport bool astraCudaFanFP(const float* pfVolume, float* pfSinogram, - unsigned int iVolWidth, unsigned int iVolHeight, - unsigned int iProjAngles, unsigned int iProjDets, - const SFanProjection *pAngles, - unsigned int iDetSuperSampling = 1, - float fOutputScale = 1.0f, int iGPUIndex = 0); - - -_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, - const CParallelProjectionGeometry2D* pProjGeom, - astraCUDA::SParProjection*& pProjs, - float& fOutputScale); - -_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, - const CParallelVecProjectionGeometry2D* pProjGeom, - astraCUDA::SParProjection*& pProjs, - float& fOutputScale); - - -_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, - const CFanFlatProjectionGeometry2D* pProjGeom, - astraCUDA::SFanProjection*& pProjs, - float& outputScale); - -_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, - const CFanFlatVecProjectionGeometry2D* pProjGeom, - astraCUDA::SFanProjection*& pProjs, - float& outputScale); - -_AstraExport bool convertAstraGeometry_dims(const CVolumeGeometry2D* pVolGeom, - const CProjectionGeometry2D* pProjGeom, - astraCUDA::SDimensions& dims); - -_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, - const CProjectionGeometry2D* pProjGeom, - astraCUDA::SParProjection*& pParProjs, - astraCUDA::SFanProjection*& pFanProjs, - float& outputScale); -} - -namespace astraCUDA { - -// Return string with CUDA device number, name and memory size. -// Use device == -1 to get info for the current device. -_AstraExport std::string getCudaDeviceString(int device); - -_AstraExport bool setGPUIndex(int index); - -_AstraExport size_t availableGPUMemory(); - -} -#endif diff --git a/cuda/2d/cgls.cu b/cuda/2d/cgls.cu index f9fd6c1..696a0c1 100644 --- a/cuda/2d/cgls.cu +++ b/cuda/2d/cgls.cu @@ -25,17 +25,17 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include - -#include "cgls.h" -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/cgls.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif +#include +#include + namespace astraCUDA { CGLS::CGLS() : ReconAlgo() diff --git a/cuda/2d/cgls.h b/cuda/2d/cgls.h deleted file mode 100644 index 375a425..0000000 --- a/cuda/2d/cgls.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_CGLS_H -#define _CUDA_CGLS_H - -#include "algo.h" - -namespace astraCUDA { - -class _AstraExport CGLS : public ReconAlgo { -public: - CGLS(); - virtual ~CGLS(); - - // disable some features - virtual bool enableSinogramMask() { return false; } - virtual bool setMinConstraint(float) { return false; } - virtual bool setMaxConstraint(float) { return false; } - - virtual bool init(); - - virtual bool setBuffers(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch); - - virtual bool copyDataToGPU(const float* pfSinogram, unsigned int iSinogramPitch, float fSinogramScale, - const float* pfReconstruction, unsigned int iReconstructionPitch, - const float* pfVolMask, unsigned int iVolMaskPitch, - const float* pfSinoMask, unsigned int iSinoMaskPitch); - - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm(); - -protected: - void reset(); - - bool sliceInitialized; - - // Buffers - float* D_r; - unsigned int rPitch; - - float* D_w; - unsigned int wPitch; - - float* D_z; - unsigned int zPitch; - - float* D_p; - unsigned int pPitch; - - - float gamma; -}; - - -_AstraExport bool doCGLS(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const float* angles, - const float* TOffsets, unsigned int iterations); - -} - -#endif diff --git a/cuda/2d/darthelper.cu b/cuda/2d/darthelper.cu index 4041d79..b466840 100644 --- a/cuda/2d/darthelper.cu +++ b/cuda/2d/darthelper.cu @@ -25,8 +25,9 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "util.h" -#include "darthelper.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/darthelper.h" + #include namespace astraCUDA { diff --git a/cuda/2d/darthelper.h b/cuda/2d/darthelper.h deleted file mode 100644 index 3c2f83c..0000000 --- a/cuda/2d/darthelper.h +++ /dev/null @@ -1,41 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ARITH2_H -#define _CUDA_ARITH2_H - -#include "astra/Globals.h" - -namespace astraCUDA { - - void roiSelect(float* out, float radius, unsigned int width, unsigned int height); - void dartMask(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, unsigned int width, unsigned int height); - void dartSmoothing(float* out, const float* in, float b, unsigned int radius, unsigned int width, unsigned int height); - -} - -#endif diff --git a/cuda/2d/dims.h b/cuda/2d/dims.h deleted file mode 100644 index 0bdefa9..0000000 --- a/cuda/2d/dims.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_DIMS_H -#define _CUDA_DIMS_H - -#include "astra/GeometryUtil2D.h" - - -namespace astraCUDA { - -using astra::SParProjection; -using astra::SFanProjection; - - - -struct SDimensions { - // Width, height of reconstruction volume - unsigned int iVolWidth; - unsigned int iVolHeight; - - // Number of projection angles - unsigned int iProjAngles; - - // Number of detector pixels - unsigned int iProjDets; - - // in FP, number of rays to trace per detector pixel. - // This should usually be set to 1. - // If fDetScale > 1, this should be set to an integer of roughly - // the same size as fDetScale. - unsigned int iRaysPerDet; - - // in BP, square root of number of rays to trace per volume pixel - // This should usually be set to 1. - // If fDetScale < 1, this should be set to an integer of roughly - // the same size as 1 / fDetScale. - unsigned int iRaysPerPixelDim; -}; - -} - -#endif - diff --git a/cuda/2d/em.cu b/cuda/2d/em.cu index cf67f9b..ca09d31 100644 --- a/cuda/2d/em.cu +++ b/cuda/2d/em.cu @@ -25,17 +25,17 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include - -#include "em.h" -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/em.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif +#include +#include + namespace astraCUDA { diff --git a/cuda/2d/em.h b/cuda/2d/em.h deleted file mode 100644 index 3ffe01b..0000000 --- a/cuda/2d/em.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_EM_H -#define _CUDA_EM_H - -#include "algo.h" - -namespace astraCUDA { - -class _AstraExport EM : public ReconAlgo { -public: - EM(); - virtual ~EM(); - - // disable some features - virtual bool enableSinogramMask() { return false; } - virtual bool enableVolumeMask() { return false; } - virtual bool setMinConstraint(float) { return false; } - virtual bool setMaxConstraint(float) { return false; } - - virtual bool init(); - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm(); - -protected: - void reset(); - bool precomputeWeights(); - - // Temporary buffers - float* D_projData; - unsigned int projPitch; - - float* D_tmpData; - unsigned int tmpPitch; - - // Geometry-specific precomputed data - float* D_pixelWeight; - unsigned int pixelPitch; -}; - -_AstraExport bool doEM(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const float* angles, - const float* TOffsets, unsigned int iterations); - -} - -#endif diff --git a/cuda/2d/fan_bp.cu b/cuda/2d/fan_bp.cu index 793b5f4..dac3ac2 100644 --- a/cuda/2d/fan_bp.cu +++ b/cuda/2d/fan_bp.cu @@ -25,18 +25,16 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include -#include - -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif -#define PIXELTRACE +#include +#include +#include typedef texture texture2D; diff --git a/cuda/2d/fan_bp.h b/cuda/2d/fan_bp.h deleted file mode 100644 index 22349b0..0000000 --- a/cuda/2d/fan_bp.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_FAN_BP_H -#define _CUDA_FAN_BP_H - -namespace astraCUDA { - -_AstraExport bool FanBP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const SFanProjection* angles, - float fOutputScale); - -_AstraExport bool FanBP_SART(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - unsigned int angle, - const SDimensions& dims, const SFanProjection* angles, - float fOutputScale); - -_AstraExport bool FanBP_FBPWeighted(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const SFanProjection* angles, - float fOutputScale); - - -} - -#endif diff --git a/cuda/2d/fan_fp.cu b/cuda/2d/fan_fp.cu index f08a681..3479650 100644 --- a/cuda/2d/fan_fp.cu +++ b/cuda/2d/fan_fp.cu @@ -25,18 +25,18 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include -#include -#include - -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif +#include +#include +#include +#include + typedef texture texture2D; diff --git a/cuda/2d/fan_fp.h b/cuda/2d/fan_fp.h deleted file mode 100644 index 3e8f1e4..0000000 --- a/cuda/2d/fan_fp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_FAN_FP_H -#define _CUDA_FAN_FP_H - -namespace astraCUDA { - -_AstraExport bool FanFP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const SFanProjection* angles, - float outputScale); - -} - -#endif diff --git a/cuda/2d/fbp.cu b/cuda/2d/fbp.cu index ecaf544..48fb7dc 100644 --- a/cuda/2d/fbp.cu +++ b/cuda/2d/fbp.cu @@ -25,14 +25,14 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "fbp.h" -#include "fft.h" -#include "par_bp.h" -#include "fan_bp.h" -#include "util.h" +#include "astra/cuda/2d/fbp.h" +#include "astra/cuda/2d/fft.h" +#include "astra/cuda/2d/par_bp.h" +#include "astra/cuda/2d/fan_bp.h" +#include "astra/cuda/2d/util.h" // For fan-beam preweighting -#include "../3d/fdk.h" +#include "astra/cuda/3d/fdk.h" #include "astra/Logging.h" diff --git a/cuda/2d/fbp.h b/cuda/2d/fbp.h deleted file mode 100644 index 8666646..0000000 --- a/cuda/2d/fbp.h +++ /dev/null @@ -1,97 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#include "algo.h" -#include "fbp_filters.h" - -namespace astraCUDA { - -class _AstraExport FBP : public ReconAlgo { -public: - FBP(); - ~FBP(); - - virtual bool useSinogramMask() { return false; } - virtual bool useVolumeMask() { return false; } - - // Returns the required size of a filter in the fourier domain - // when multiplying it with the fft of the projection data. - // Its value is equal to the smallest power of two larger than - // or equal to twice the number of detectors in the spatial domain. - // - // _iDetectorCount is the number of detectors in the spatial domain. - static int calcFourierFilterSize(int _iDetectorCount); - - // Sets the filter type. Some filter types require the user to supply an - // array containing the filter. - // The number of elements in a filter in the fourier domain should be equal - // to the value returned by calcFourierFilterSize(). - // The following types require a filter: - // - // - FILTER_PROJECTION: - // The filter size should be equal to the output of - // calcFourierFilterSize(). The filtered sinogram is - // multiplied with the supplied filter. - // - // - FILTER_SINOGRAM: - // Same as FILTER_PROJECTION, but now the filter should contain a row for - // every projection direction. - // - // - FILTER_RPROJECTION: - // The filter should now contain one kernel (= ifft of filter), with the - // peak in the center. The filter width - // can be any value. If odd, the peak is assumed to be in the center, if - // even, it is assumed to be at floor(filter-width/2). - // - // - FILTER_RSINOGRAM - // Same as FILTER_RPROJECTION, but now the supplied filter should contain a - // row for every projection direction. - // - // A large number of other filters (FILTER_RAMLAK, FILTER_SHEPPLOGAN, - // FILTER_COSINE, FILTER_HAMMING, and FILTER_HANN) - // have a D variable, which gives the cutoff point in the frequency domain. - // Setting this value to 1.0 will include the whole filter - bool setFilter(astra::E_FBPFILTER _eFilter, - const float * _pfHostFilter = NULL, - int _iFilterWidth = 0, float _fD = 1.0f, float _fFilterParameter = -1.0f); - - bool setShortScan(bool ss) { m_bShortScan = ss; return true; } - - virtual bool init(); - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm() { return 0.0f; } // TODO - -protected: - void reset(); - - void* D_filter; // cufftComplex* - bool m_bShortScan; -}; - -} diff --git a/cuda/2d/fbp_filters.h b/cuda/2d/fbp_filters.h deleted file mode 100644 index 7c1121a..0000000 --- a/cuda/2d/fbp_filters.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef FBP_FILTERS_H -#define FBP_FILTERS_H - -namespace astra { - -enum E_FBPFILTER -{ - FILTER_NONE, //< no filter (regular BP) - FILTER_RAMLAK, //< default FBP filter - FILTER_SHEPPLOGAN, //< Shepp-Logan - FILTER_COSINE, //< Cosine - FILTER_HAMMING, //< Hamming filter - FILTER_HANN, //< Hann filter - FILTER_TUKEY, //< Tukey filter - FILTER_LANCZOS, //< Lanczos filter - FILTER_TRIANGULAR, //< Triangular filter - FILTER_GAUSSIAN, //< Gaussian filter - FILTER_BARTLETTHANN, //< Bartlett-Hann filter - FILTER_BLACKMAN, //< Blackman filter - FILTER_NUTTALL, //< Nuttall filter, continuous first derivative - FILTER_BLACKMANHARRIS, //< Blackman-Harris filter - FILTER_BLACKMANNUTTALL, //< Blackman-Nuttall filter - FILTER_FLATTOP, //< Flat top filter - FILTER_KAISER, //< Kaiser filter - FILTER_PARZEN, //< Parzen filter - FILTER_PROJECTION, //< all projection directions share one filter - FILTER_SINOGRAM, //< every projection direction has its own filter - FILTER_RPROJECTION, //< projection filter in real space (as opposed to fourier space) - FILTER_RSINOGRAM, //< sinogram filter in real space -}; - -} - -#endif /* FBP_FILTERS_H */ diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index a1b1b93..bd8cab5 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -25,16 +25,18 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "fft.h" -#include "util.h" +#include "astra/cuda/2d/fft.h" +#include "astra/cuda/2d/util.h" + +#include "astra/Logging.h" +#include "astra/Fourier.h" -#include #include -#include #include -#include "../../include/astra/Logging.h" -#include "../../include/astra/Fourier.h" +#include +#include + using namespace astra; diff --git a/cuda/2d/fft.h b/cuda/2d/fft.h deleted file mode 100644 index d36cae2..0000000 --- a/cuda/2d/fft.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef FFT_H -#define FFT_H - -#include -#include - -#include "fbp_filters.h" - -namespace astraCUDA { - -bool allocateComplexOnDevice(int _iProjectionCount, - int _iDetectorCount, - cufftComplex ** _ppDevComplex); - -bool freeComplexOnDevice(cufftComplex * _pDevComplex); - -bool uploadComplexArrayToDevice(int _iProjectionCount, int _iDetectorCount, - cufftComplex * _pHostComplexSource, - cufftComplex * _pDevComplexTarget); - -bool runCudaFFT(int _iProjectionCount, const float * _pfDevRealSource, - int _iSourcePitch, int _iProjDets, - int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount, - cufftComplex * _pDevTargetComplex); - -bool runCudaIFFT(int _iProjectionCount, const cufftComplex* _pDevSourceComplex, - float * _pfRealTarget, - int _iTargetPitch, int _iProjDets, - int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); - -void applyFilter(int _iProjectionCount, int _iFreqBinCount, - cufftComplex * _pSinogram, cufftComplex * _pFilter); - -int calcFFTFourierSize(int _iFFTRealSize); - -void genFilter(astra::E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, - cufftComplex * _pFilter, int _iFFTRealDetectorCount, - int _iFFTFourierDetectorCount, float _fParameter = -1.0f); - -void genIdenFilter(int _iProjectionCount, cufftComplex * _pFilter, - int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); - -} - -#endif /* FFT_H */ diff --git a/cuda/2d/par_bp.cu b/cuda/2d/par_bp.cu index a894f3f..09a6554 100644 --- a/cuda/2d/par_bp.cu +++ b/cuda/2d/par_bp.cu @@ -25,18 +25,16 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include -#include - -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif -#define PIXELTRACE +#include +#include +#include typedef texture texture2D; diff --git a/cuda/2d/par_bp.h b/cuda/2d/par_bp.h deleted file mode 100644 index c8dfab8..0000000 --- a/cuda/2d/par_bp.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_PAR_BP_H -#define _CUDA_PAR_BP_H - -#include "dims.h" - -namespace astraCUDA { - -_AstraExport bool BP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const SParProjection* angles, - float fOutputScale); - -_AstraExport bool BP_SART(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - unsigned int angle, const SDimensions& dims, - const SParProjection* angles, float fOutputScale); - -} - -#endif diff --git a/cuda/2d/par_fp.cu b/cuda/2d/par_fp.cu index 427a4e8..0835301 100644 --- a/cuda/2d/par_fp.cu +++ b/cuda/2d/par_fp.cu @@ -25,21 +25,18 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include -#include -#include -#include - -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif -#define PIXELTRACE - +#include +#include +#include +#include +#include typedef texture texture2D; diff --git a/cuda/2d/par_fp.h b/cuda/2d/par_fp.h deleted file mode 100644 index 62277a1..0000000 --- a/cuda/2d/par_fp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_PAR_FP_H -#define _CUDA_PAR_FP_H - -namespace astraCUDA { - -_AstraExport bool FP(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - const SDimensions& dims, const SParProjection* angles, - float fOutputScale); - -} - -#endif diff --git a/cuda/2d/sart.cu b/cuda/2d/sart.cu index 8b6f50e..cf9babc 100644 --- a/cuda/2d/sart.cu +++ b/cuda/2d/sart.cu @@ -25,17 +25,17 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/2d/sart.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" +#include "astra/cuda/2d/fan_fp.h" +#include "astra/cuda/2d/fan_bp.h" +#include "astra/cuda/2d/par_fp.h" +#include "astra/cuda/2d/par_bp.h" + #include #include -#include "sart.h" -#include "util.h" -#include "arith.h" -#include "fan_fp.h" -#include "fan_bp.h" -#include "par_fp.h" -#include "par_bp.h" - namespace astraCUDA { // FIXME: Remove these functions. (Outdated) diff --git a/cuda/2d/sart.h b/cuda/2d/sart.h deleted file mode 100644 index 6c0e547..0000000 --- a/cuda/2d/sart.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_SART_H -#define _CUDA_SART_H - -#include "algo.h" - -namespace astraCUDA { - -class _AstraExport SART : public ReconAlgo { -public: - SART(); - ~SART(); - - // disable some features - virtual bool enableSinogramMask() { return false; } - - virtual bool init(); - - virtual bool setProjectionOrder(int* projectionOrder, int projectionCount); - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm(); - - void setRelaxation(float r) { fRelaxation = r; } - -protected: - void reset(); - bool precomputeWeights(); - - bool callFP_SART(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - unsigned int angle, float outputScale); - bool callBP_SART(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - unsigned int angle, float outputScale); - - - // projection angle variables - bool customOrder; - int* projectionOrder; - int projectionCount; - int iteration; - - // Temporary buffers - float* D_projData; - unsigned int projPitch; - - float* D_tmpData; // Only used when there's a volume mask - unsigned int tmpPitch; - - // Geometry-specific precomputed data - float* D_lineWeight; - unsigned int linePitch; - - float fRelaxation; -}; - -} - -#endif diff --git a/cuda/2d/sirt.cu b/cuda/2d/sirt.cu index faba7a7..7ec377c 100644 --- a/cuda/2d/sirt.cu +++ b/cuda/2d/sirt.cu @@ -25,17 +25,17 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include - -#include "sirt.h" -#include "util.h" -#include "arith.h" +#include "astra/cuda/2d/sirt.h" +#include "astra/cuda/2d/util.h" +#include "astra/cuda/2d/arith.h" #ifdef STANDALONE #include "testutil.h" #endif +#include +#include + namespace astraCUDA { SIRT::SIRT() : ReconAlgo() diff --git a/cuda/2d/sirt.h b/cuda/2d/sirt.h deleted file mode 100644 index 434a07c..0000000 --- a/cuda/2d/sirt.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_SIRT_H -#define _CUDA_SIRT_H - -#include "algo.h" - -namespace astraCUDA { - -class _AstraExport SIRT : public ReconAlgo { -public: - SIRT(); - ~SIRT(); - - virtual bool init(); - - // Do optional long-object compensation. See the comments in sirt.cu. - // Call this after init(). It can not be used in combination with masks. - bool doSlabCorrections(); - - // Set min/max masks to existing GPU memory buffers - bool setMinMaxMasks(float* D_minMaskData, float* D_maxMaskData, - unsigned int pitch); - - // Set min/max masks from RAM buffers - bool uploadMinMaxMasks(const float* minMaskData, const float* maxMaskData, - unsigned int pitch); - - void setRelaxation(float r) { fRelaxation = r; } - - virtual bool iterate(unsigned int iterations); - - virtual float computeDiffNorm(); - -protected: - void reset(); - bool precomputeWeights(); - - // Temporary buffers - float* D_projData; - unsigned int projPitch; - - float* D_tmpData; - unsigned int tmpPitch; - - // Geometry-specific precomputed data - float* D_lineWeight; - unsigned int linePitch; - - float* D_pixelWeight; - unsigned int pixelPitch; - - // Masks - bool freeMinMaxMasks; - float* D_minMaskData; - unsigned int minMaskPitch; - float* D_maxMaskData; - unsigned int maxMaskPitch; - - float fRelaxation; -}; - -bool doSIRT(float* D_volumeData, unsigned int volumePitch, - float* D_projData, unsigned int projPitch, - float* D_maskData, unsigned int maskPitch, - const SDimensions& dims, const float* angles, - const float* TOffsets, unsigned int iterations); - -} - -#endif diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index dfc5de9..533b86c 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -25,11 +25,12 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/2d/util.h" + +#include "astra/Logging.h" + #include #include -#include "util.h" - -#include "../../include/astra/Logging.h" namespace astraCUDA { diff --git a/cuda/2d/util.h b/cuda/2d/util.h deleted file mode 100644 index 70e7c86..0000000 --- a/cuda/2d/util.h +++ /dev/null @@ -1,84 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_UTIL_H -#define _CUDA_UTIL_H - -#include -#include -#include - -#include "astra/Globals.h" - -#include "dims.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define ASTRA_CUDA_ASSERT(err) do { if (err != cudaSuccess) { astraCUDA::reportCudaError(err); assert(err == cudaSuccess); } } while(0) - - -namespace astraCUDA { - -bool copyVolumeToDevice(const float* in_data, unsigned int in_pitch, - const SDimensions& dims, - float* outD_data, unsigned int out_pitch); -bool copyVolumeFromDevice(float* out_data, unsigned int out_pitch, - const SDimensions& dims, - float* inD_data, unsigned int in_pitch); -bool copySinogramFromDevice(float* out_data, unsigned int out_pitch, - const SDimensions& dims, - float* inD_data, unsigned int in_pitch); -bool copySinogramToDevice(const float* in_data, unsigned int in_pitch, - const SDimensions& dims, - float* outD_data, unsigned int out_pitch); - -bool allocateVolume(float*& D_ptr, unsigned int width, unsigned int height, unsigned int& pitch); -void zeroVolume(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); - -bool allocateVolumeData(float*& D_ptr, unsigned int& pitch, const SDimensions& dims); -bool allocateProjectionData(float*& D_ptr, unsigned int& pitch, const SDimensions& dims); -void zeroVolumeData(float* D_ptr, unsigned int pitch, const SDimensions& dims); -void zeroProjectionData(float* D_ptr, unsigned int pitch, const SDimensions& dims); - -void duplicateVolumeData(float* D_dst, float* D_src, unsigned int pitch, const SDimensions& dims); -void duplicateProjectionData(float* D_dst, float* D_src, unsigned int pitch, const SDimensions& dims); - - - -bool cudaTextForceKernelsCompletion(); -void reportCudaError(cudaError_t err); - - - -float dotProduct2D(float* D_data, unsigned int pitch, - unsigned int width, unsigned int height); - -} - -#endif diff --git a/cuda/3d/algo3d.cu b/cuda/3d/algo3d.cu index ee7a23b..b4a435b 100644 --- a/cuda/3d/algo3d.cu +++ b/cuda/3d/algo3d.cu @@ -25,13 +25,13 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include +#include "astra/cuda/3d/algo3d.h" +#include "astra/cuda/3d/cone_fp.h" +#include "astra/cuda/3d/cone_bp.h" +#include "astra/cuda/3d/par3d_fp.h" +#include "astra/cuda/3d/par3d_bp.h" -#include "algo3d.h" -#include "cone_fp.h" -#include "cone_bp.h" -#include "par3d_fp.h" -#include "par3d_bp.h" +#include namespace astraCUDA3d { diff --git a/cuda/3d/algo3d.h b/cuda/3d/algo3d.h deleted file mode 100644 index f5fd207..0000000 --- a/cuda/3d/algo3d.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ALGO_H -#define _CUDA_ALGO_H - -#include "dims3d.h" -#include "util3d.h" - -namespace astraCUDA3d { - -class _AstraExport ReconAlgo3D { -public: - ReconAlgo3D(); - ~ReconAlgo3D(); - - bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs, const SProjectorParams3D& params); - bool setPar3DGeometry(const SDimensions3D& dims, const SPar3DProjection* projs, const SProjectorParams3D& params); - - void signalAbort() { shouldAbort = true; } - -protected: - void reset(); - - bool callFP(cudaPitchedPtr& D_volumeData, - cudaPitchedPtr& D_projData, - float outputScale); - bool callBP(cudaPitchedPtr& D_volumeData, - cudaPitchedPtr& D_projData, - float outputScale); - - SDimensions3D dims; - SProjectorParams3D params; - SConeProjection* coneProjs; - SPar3DProjection* par3DProjs; - - float fOutputScale; - - volatile bool shouldAbort; - -}; - - -} - -#endif - diff --git a/cuda/3d/arith3d.cu b/cuda/3d/arith3d.cu index 05b94ce..2f4054e 100644 --- a/cuda/3d/arith3d.cu +++ b/cuda/3d/arith3d.cu @@ -25,8 +25,9 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "util3d.h" -#include "arith3d.h" +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/arith3d.h" + #include namespace astraCUDA3d { diff --git a/cuda/3d/arith3d.h b/cuda/3d/arith3d.h deleted file mode 100644 index fa9f3a1..0000000 --- a/cuda/3d/arith3d.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ARITH3D_H -#define _CUDA_ARITH3D_H - -#include - -namespace astraCUDA3d { - -struct opAddScaled; -struct opScaleAndAdd; -struct opAddMulScaled; -struct opAddMul; -struct opAdd; -struct opMul; -struct opMul2; -struct opDividedBy; -struct opInvert; -struct opSet; -struct opClampMin; -struct opClampMax; - -enum VolType { - SINO = 0, - VOL = 1 -}; - - -template void processVol(CUdeviceptr* out, unsigned int pitch, unsigned int width, unsigned int height); -template void processVol(CUdeviceptr* out, float fParam, unsigned int pitch, unsigned int width, unsigned int height); -template void processVol(CUdeviceptr* out, const CUdeviceptr* in, unsigned int pitch, unsigned int width, unsigned int height); -template void processVol(CUdeviceptr* out, const CUdeviceptr* in, float fParam, unsigned int pitch, unsigned int width, unsigned int height); -template void processVol(CUdeviceptr* out, const CUdeviceptr* in1, const CUdeviceptr* in2, float fParam, unsigned int pitch, unsigned int width, unsigned int height); -template void processVol(CUdeviceptr* out, const CUdeviceptr* in1, const CUdeviceptr* in2, unsigned int pitch, unsigned int width, unsigned int height); - -template void processVol3D(cudaPitchedPtr& out, const SDimensions3D& dims); -template void processVol3D(cudaPitchedPtr& out, float fParam, const SDimensions3D& dims); -template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, const SDimensions3D& dims); -template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, float fParam, const SDimensions3D& dims); -template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, float fParam, const SDimensions3D& dims); -template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, const SDimensions3D& dims); - -template void processSino3D(cudaPitchedPtr& out, const SDimensions3D& dims); -template void processSino3D(cudaPitchedPtr& out, float fParam, const SDimensions3D& dims); -template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, const SDimensions3D& dims); -template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, float fParam, const SDimensions3D& dims); -template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, float fParam, const SDimensions3D& dims); -template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, const SDimensions3D& dims); - - - -} - -#endif diff --git a/cuda/3d/astra3d.cu b/cuda/3d/astra3d.cu index c0f4c4a..23af36a 100644 --- a/cuda/3d/astra3d.cu +++ b/cuda/3d/astra3d.cu @@ -25,19 +25,16 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include - -#include "cgls3d.h" -#include "sirt3d.h" -#include "util3d.h" -#include "cone_fp.h" -#include "cone_bp.h" -#include "par3d_fp.h" -#include "par3d_bp.h" -#include "fdk.h" -#include "arith3d.h" -#include "astra3d.h" +#include "astra/cuda/3d/cgls3d.h" +#include "astra/cuda/3d/sirt3d.h" +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/cone_fp.h" +#include "astra/cuda/3d/cone_bp.h" +#include "astra/cuda/3d/par3d_fp.h" +#include "astra/cuda/3d/par3d_bp.h" +#include "astra/cuda/3d/fdk.h" +#include "astra/cuda/3d/arith3d.h" +#include "astra/cuda/3d/astra3d.h" #include "astra/ParallelProjectionGeometry3D.h" #include "astra/ParallelVecProjectionGeometry3D.h" @@ -46,6 +43,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/VolumeGeometry3D.h" #include +#include +#include using namespace astraCUDA3d; diff --git a/cuda/3d/astra3d.h b/cuda/3d/astra3d.h deleted file mode 100644 index 0ea752d..0000000 --- a/cuda/3d/astra3d.h +++ /dev/null @@ -1,314 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_ASTRA3D_H -#define _CUDA_ASTRA3D_H - -#include "dims3d.h" - -namespace astra { - - -// TODO: Switch to a class hierarchy as with the 2D algorithms - - -class CProjectionGeometry3D; -class CParallelProjectionGeometry3D; -class CParallelVecProjectionGeometry3D; -class CConeProjectionGeometry3D; -class CConeVecProjectionGeometry3D; -class CVolumeGeometry3D; -class AstraSIRT3d_internal; - -using astraCUDA3d::Cuda3DProjectionKernel; -using astraCUDA3d::ker3d_default; -using astraCUDA3d::ker3d_sum_square_weights; - - -class _AstraExport AstraSIRT3d { -public: - - AstraSIRT3d(); - ~AstraSIRT3d(); - - // Set the volume and projection geometry - bool setGeometry(const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom); - - // Enable supersampling. - // - // The number of rays used in FP is the square of iDetectorSuperSampling. - // The number of rays used in BP is the cube of iVoxelSuperSampling. - bool enableSuperSampling(unsigned int iVoxelSuperSampling, - unsigned int iDetectorSuperSampling); - - void setRelaxation(float r); - - // Enable volume/sinogram masks - // - // This may optionally be called before init(). - // If it is called, setVolumeMask()/setSinogramMask() must be called between - // setSinogram() and iterate(). - bool enableVolumeMask(); - bool enableSinogramMask(); - - // Set GPU index - // - // This should be called before init(). Note that setting the GPU index - // in a thread which has already used the GPU may not work. - bool setGPUIndex(int index); - - // Allocate GPU buffers and - // precompute geometry-specific data. - // - // This must be called after calling setReconstructionGeometry() and - // setProjectionGeometry() or setFanProjectionGeometry(). - bool init(); - - // Setup input sinogram for a slice. - // pfSinogram must be a float array of size XXX - // NB: iSinogramPitch is measured in floats, not in bytes. - // - // This must be called after init(), and before iterate(). It may be - // called again after iterate()/getReconstruction() to start a new slice. - // - // pfSinogram will only be read from during this call. - bool setSinogram(const float* pfSinogram, unsigned int iSinogramPitch); - - // Setup volume mask for a slice. - // pfMask must be a float array of size XXX - // NB: iMaskPitch is measured in floats, not in bytes. - // - // It may only contain the exact values 0.0f and 1.0f. Only volume pixels - // for which pfMask[z] is 1.0f are processed. - bool setVolumeMask(const float* pfMask, unsigned int iMaskPitch); - - // Setup sinogram mask for a slice. - // pfMask must be a float array of size XXX - // NB: iMaskPitch is measured in floats, not in bytes. - // - // It may only contain the exact values 0.0f and 1.0f. Only sinogram pixels - // for which pfMask[z] is 1.0f are processed. - bool setSinogramMask(const float* pfMask, unsigned int iMaskPitch); - - // Set the starting reconstruction for SIRT. - // pfReconstruction must be a float array of size XXX - // NB: iReconstructionPitch is measured in floats, not in bytes. - // - // This may be called between setSinogram() and iterate(). - // If this function is not called before iterate(), SIRT will start - // from a zero reconstruction. - // - // pfReconstruction will only be read from during this call. - bool setStartReconstruction(const float* pfReconstruction, - unsigned int iReconstructionPitch); - - // Enable min/max constraint. - // - // These may optionally be called between init() and iterate() - bool setMinConstraint(float fMin); - bool setMaxConstraint(float fMax); - - // Perform a number of (additive) SIRT iterations. - // This must be called after setSinogram(). - // - // If called multiple times, without calls to setSinogram() or - // setStartReconstruction() in between, iterate() will continue from - // the result of the previous call. - // Calls to getReconstruction() are allowed between calls to iterate() and - // do not change the state. - bool iterate(unsigned int iIterations); - - // Get the reconstructed slice. - // pfReconstruction must be a float array of size XXX - // NB: iReconstructionPitch is measured in floats, not in bytes. - // - // This may be called after iterate(). - bool getReconstruction(float* pfReconstruction, - unsigned int iReconstructionPitch) const; - - // Compute the norm of the difference of the FP of the current - // reconstruction and the sinogram. (This performs one FP.) - // It can be called after iterate(). - float computeDiffNorm(); - - // Signal the algorithm that it should abort after the current iteration. - // This is intended to be called from another thread. - void signalAbort(); - -protected: - AstraSIRT3d_internal *pData; -}; - - -class AstraCGLS3d_internal; - - -class _AstraExport AstraCGLS3d { -public: - - AstraCGLS3d(); - ~AstraCGLS3d(); - - // Set the volume and projection geometry - bool setGeometry(const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom); - - // Enable supersampling. - // - // The number of rays used in FP is the square of iDetectorSuperSampling. - // The number of rays used in BP is the cube of iVoxelSuperSampling. - bool enableSuperSampling(unsigned int iVoxelSuperSampling, - unsigned int iDetectorSuperSampling); - - // Enable volume/sinogram masks - // - // This may optionally be called before init(). - // If it is called, setVolumeMask()/setSinogramMask() must be called between - // setSinogram() and iterate(). - bool enableVolumeMask(); - //bool enableSinogramMask(); - - // Set GPU index - // - // This should be called before init(). Note that setting the GPU index - // in a thread which has already used the GPU may not work. - bool setGPUIndex(int index); - - // Allocate GPU buffers and - // precompute geometry-specific data. - // - // This must be called after calling setReconstructionGeometry() and - // setProjectionGeometry() or setFanProjectionGeometry(). - bool init(); - - // Setup input sinogram for a slice. - // pfSinogram must be a float array of size XXX - // NB: iSinogramPitch is measured in floats, not in bytes. - // - // This must be called after init(), and before iterate(). It may be - // called again after iterate()/getReconstruction() to start a new slice. - // - // pfSinogram will only be read from during this call. - bool setSinogram(const float* pfSinogram, unsigned int iSinogramPitch); - - // Setup volume mask for a slice. - // pfMask must be a float array of size XXX - // NB: iMaskPitch is measured in floats, not in bytes. - // - // It may only contain the exact values 0.0f and 1.0f. Only volume pixels - // for which pfMask[z] is 1.0f are processed. - bool setVolumeMask(const float* pfMask, unsigned int iMaskPitch); - - // Setup sinogram mask for a slice. - // pfMask must be a float array of size XXX - // NB: iMaskPitch is measured in floats, not in bytes. - // - // It may only contain the exact values 0.0f and 1.0f. Only sinogram pixels - // for which pfMask[z] is 1.0f are processed. - //bool setSinogramMask(const float* pfMask, unsigned int iMaskPitch); - - // Set the starting reconstruction for SIRT. - // pfReconstruction must be a float array of size XXX - // NB: iReconstructionPitch is measured in floats, not in bytes. - // - // This may be called between setSinogram() and iterate(). - // If this function is not called before iterate(), SIRT will start - // from a zero reconstruction. - // - // pfReconstruction will only be read from during this call. - bool setStartReconstruction(const float* pfReconstruction, - unsigned int iReconstructionPitch); - - // Enable min/max constraint. - // - // These may optionally be called between init() and iterate() - //bool setMinConstraint(float fMin); - //bool setMaxConstraint(float fMax); - - // Perform a number of (additive) SIRT iterations. - // This must be called after setSinogram(). - // - // If called multiple times, without calls to setSinogram() or - // setStartReconstruction() in between, iterate() will continue from - // the result of the previous call. - // Calls to getReconstruction() are allowed between calls to iterate() and - // do not change the state. - bool iterate(unsigned int iIterations); - - // Get the reconstructed slice. - // pfReconstruction must be a float array of size XXX - // NB: iReconstructionPitch is measured in floats, not in bytes. - // - // This may be called after iterate(). - bool getReconstruction(float* pfReconstruction, - unsigned int iReconstructionPitch) const; - - // Compute the norm of the difference of the FP of the current - // reconstruction and the sinogram. (This performs one FP.) - // It can be called after iterate(). - float computeDiffNorm(); - - // Signal the algorithm that it should abort after the current iteration. - // This is intended to be called from another thread. - void signalAbort(); - -protected: - AstraCGLS3d_internal *pData; -}; - -bool convertAstraGeometry_dims(const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom, - astraCUDA3d::SDimensions3D& dims); - -bool convertAstraGeometry(const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom, - SPar3DProjection*& pParProjs, - SConeProjection*& pConeProjs, - astraCUDA3d::SProjectorParams3D& params); - -_AstraExport bool astraCudaFP(const float* pfVolume, float* pfProjections, - const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom, - int iGPUIndex, int iDetectorSuperSampling, - Cuda3DProjectionKernel projKernel); - - -_AstraExport bool astraCudaBP(float* pfVolume, const float* pfProjections, - const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom, - int iGPUIndex, int iVoxelSuperSampling); - -_AstraExport bool astraCudaBP_SIRTWeighted(float* pfVolume, const float* pfProjections, - const CVolumeGeometry3D* pVolGeom, - const CProjectionGeometry3D* pProjGeom, - int iGPUIndex, int iVoxelSuperSampling); - -} - - -#endif diff --git a/cuda/3d/cgls3d.cu b/cuda/3d/cgls3d.cu index 7e31749..0df10f0 100644 --- a/cuda/3d/cgls3d.cu +++ b/cuda/3d/cgls3d.cu @@ -25,14 +25,14 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/cgls3d.h" +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/arith3d.h" +#include "astra/cuda/3d/cone_fp.h" + #include #include -#include "cgls3d.h" -#include "util3d.h" -#include "arith3d.h" -#include "cone_fp.h" - #ifdef STANDALONE #include "testutil.h" #endif diff --git a/cuda/3d/cgls3d.h b/cuda/3d/cgls3d.h deleted file mode 100644 index b9b9e3a..0000000 --- a/cuda/3d/cgls3d.h +++ /dev/null @@ -1,112 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_CGLS3D_H -#define _CUDA_CGLS3D_H - -#include "algo3d.h" - -namespace astraCUDA3d { - -class _AstraExport CGLS : public ReconAlgo3D { -public: - CGLS(); - ~CGLS(); - -// bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs); - - - bool enableVolumeMask(); - bool enableSinogramMask(); - - // init should be called after setting all geometry - bool init(); - - // setVolumeMask should be called after init and before iterate, - // but only if enableVolumeMask was called before init. - // It may be called again after iterate. - bool setVolumeMask(cudaPitchedPtr& D_maskData); - - // setSinogramMask should be called after init and before iterate, - // but only if enableSinogramMask was called before init. - // It may be called again after iterate. - bool setSinogramMask(cudaPitchedPtr& D_smaskData); - - - // setBuffers should be called after init and before iterate. - // It may be called again after iterate. - bool setBuffers(cudaPitchedPtr& D_volumeData, - cudaPitchedPtr& D_projData); - - - // set Min/Max constraints. They may be called at any time, and will affect - // any iterate() calls afterwards. - bool setMinConstraint(float fMin) { return false; } - bool setMaxConstraint(float fMax) { return false; } - - // iterate should be called after init and setBuffers. - // It may be called multiple times. - bool iterate(unsigned int iterations); - - // Compute the norm of the difference of the FP of the current reconstruction - // and the sinogram. (This performs one FP.) - // It can be called after iterate. - float computeDiffNorm(); - -protected: - void reset(); - - bool useVolumeMask; - bool useSinogramMask; - - cudaPitchedPtr D_maskData; - cudaPitchedPtr D_smaskData; - - // Input/output - cudaPitchedPtr D_sinoData; - cudaPitchedPtr D_volumeData; - - // Temporary buffers - cudaPitchedPtr D_r; - cudaPitchedPtr D_w; - cudaPitchedPtr D_z; - cudaPitchedPtr D_p; - - float gamma; - - bool sliceInitialized; -}; - -_AstraExport bool doCGLS(cudaPitchedPtr D_volumeData, unsigned int volumePitch, - cudaPitchedPtr D_projData, unsigned int projPitch, - cudaPitchedPtr D_maskData, unsigned int maskPitch, - const SDimensions3D& dims, const SConeProjection* projs, - unsigned int iterations); - -} - -#endif diff --git a/cuda/3d/cone_bp.cu b/cuda/3d/cone_bp.cu index 2d12d00..feebda2 100644 --- a/cuda/3d/cone_bp.cu +++ b/cuda/3d/cone_bp.cu @@ -25,20 +25,20 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" + +#ifdef STANDALONE +#include "astra/cuda/3d/cone_fp.h" +#include "testutil.h" +#endif + #include #include #include #include #include -#include "util3d.h" - -#ifdef STANDALONE -#include "cone_fp.h" -#include "testutil.h" -#endif - -#include "dims3d.h" typedef texture texture3D; diff --git a/cuda/3d/cone_bp.h b/cuda/3d/cone_bp.h deleted file mode 100644 index 6dcadb1..0000000 --- a/cuda/3d/cone_bp.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_CONE_BP_H -#define _CUDA_CONE_BP_H - -namespace astraCUDA3d { - -_AstraExport bool ConeBP_Array(cudaPitchedPtr D_volumeData, - cudaArray *D_projArray, - const SDimensions3D& dims, const SConeProjection* angles, - const SProjectorParams3D& params); - -_AstraExport bool ConeBP(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SConeProjection* angles, - const SProjectorParams3D& params); - -} - -#endif diff --git a/cuda/3d/cone_fp.cu b/cuda/3d/cone_fp.cu index 21598d0..7e0fae8 100644 --- a/cuda/3d/cone_fp.cu +++ b/cuda/3d/cone_fp.cu @@ -25,19 +25,19 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" + +#ifdef STANDALONE +#include "testutil.h" +#endif + #include #include #include #include #include -#include "util3d.h" - -#ifdef STANDALONE -#include "testutil.h" -#endif - -#include "dims3d.h" typedef texture texture3D; diff --git a/cuda/3d/cone_fp.h b/cuda/3d/cone_fp.h deleted file mode 100644 index 4da72d4..0000000 --- a/cuda/3d/cone_fp.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_CONE_FP_H -#define _CUDA_CONE_FP_H - -namespace astraCUDA3d { - -_AstraExport bool ConeFP_Array(cudaArray *D_volArray, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SConeProjection* angles, - const SProjectorParams3D& params); - -_AstraExport bool ConeFP(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SConeProjection* angles, - const SProjectorParams3D& params); - -} - -#endif diff --git a/cuda/3d/darthelper3d.cu b/cuda/3d/darthelper3d.cu index 473199a..d8ccfa6 100644 --- a/cuda/3d/darthelper3d.cu +++ b/cuda/3d/darthelper3d.cu @@ -25,9 +25,10 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include "util3d.h" -#include "dims3d.h" -#include "darthelper3d.h" +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" +#include "astra/cuda/3d/darthelper3d.h" + #include namespace astraCUDA3d { diff --git a/cuda/3d/darthelper3d.h b/cuda/3d/darthelper3d.h deleted file mode 100644 index 385e48e..0000000 --- a/cuda/3d/darthelper3d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_DARTHELPER3_H -#define _CUDA_DARTHELPER3_H - -#include "dims3d.h" - -namespace astraCUDA3d { - - void dartSmoothing(float* out, const float* in, float b, unsigned int radius, SDimensions3D dims); - void dartMasking(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, SDimensions3D dims); - - bool setGPUIndex(int index); - -} - -#endif diff --git a/cuda/3d/dims3d.h b/cuda/3d/dims3d.h deleted file mode 100644 index ef4ea78..0000000 --- a/cuda/3d/dims3d.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_CONE_DIMS_H -#define _CUDA_CONE_DIMS_H - -#include "astra/GeometryUtil3D.h" - - -namespace astraCUDA3d { - -using astra::SConeProjection; -using astra::SPar3DProjection; - - -enum Cuda3DProjectionKernel { - ker3d_default = 0, - ker3d_sum_square_weights -}; - - -struct SDimensions3D { - unsigned int iVolX; - unsigned int iVolY; - unsigned int iVolZ; - unsigned int iProjAngles; - unsigned int iProjU; // number of detectors in the U direction - unsigned int iProjV; // number of detectors in the V direction -}; - -struct SProjectorParams3D { - SProjectorParams3D() : - iRaysPerDetDim(1), iRaysPerVoxelDim(1), - fOutputScale(1.0f), - fVolScaleX(1.0f), fVolScaleY(1.0f), fVolScaleZ(1.0f), - ker(ker3d_default), - bFDKWeighting(false) - { } - - unsigned int iRaysPerDetDim; - unsigned int iRaysPerVoxelDim; - float fOutputScale; - float fVolScaleX; - float fVolScaleY; - float fVolScaleZ; - Cuda3DProjectionKernel ker; - bool bFDKWeighting; -}; - -} - -#endif - diff --git a/cuda/3d/fdk.cu b/cuda/3d/fdk.cu index 48194c4..8aea84d 100644 --- a/cuda/3d/fdk.cu +++ b/cuda/3d/fdk.cu @@ -25,25 +25,26 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include -#include -#include +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" +#include "astra/cuda/3d/arith3d.h" +#include "astra/cuda/3d/cone_bp.h" -#include -#include "util3d.h" +#include "astra/cuda/2d/fft.h" #ifdef STANDALONE -#include "cone_fp.h" +#include "astra/cuda/3d/cone_fp.h" #include "testutil.h" #endif -#include "dims3d.h" -#include "arith3d.h" -#include "cone_bp.h" -#include "../2d/fft.h" +#include "astra/Logging.h" -#include "../../include/astra/Logging.h" +#include +#include +#include +#include + +#include namespace astraCUDA3d { diff --git a/cuda/3d/fdk.h b/cuda/3d/fdk.h deleted file mode 100644 index 6f6e73b..0000000 --- a/cuda/3d/fdk.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_FDK_H -#define _CUDA_FDK_H - -#include "dims3d.h" - -namespace astraCUDA3d { - -bool FDK_PreWeight(cudaPitchedPtr D_projData, - float fSrcOrigin, float fDetOrigin, - float fZShift, - float fDetUSize, float fDetVSize, float fVoxSize, - bool bShortScan, - const SDimensions3D& dims, const float* angles); - -bool FDK(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SConeProjection* angles, - const SDimensions3D& dims, SProjectorParams3D params, bool bShortScan, - const float* filter); - -} - -#endif diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index 4a26921..fe3e723 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -25,23 +25,22 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/mem3d.h" +#include "astra/cuda/3d/astra3d.h" +#include "astra/cuda/3d/cone_fp.h" +#include "astra/cuda/3d/cone_bp.h" +#include "astra/cuda/3d/par3d_fp.h" +#include "astra/cuda/3d/par3d_bp.h" +#include "astra/cuda/3d/fdk.h" -#include "util3d.h" +#include "astra/cuda/2d/astra.h" -#include "mem3d.h" - -#include "../2d/astra.h" +#include "astra/Logging.h" -#include "astra3d.h" -#include "cone_fp.h" -#include "cone_bp.h" -#include "par3d_fp.h" -#include "par3d_bp.h" -#include "fdk.h" +#include +#include -#include "astra/Logging.h" namespace astraCUDA3d { diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h deleted file mode 100644 index 78e1294..0000000 --- a/cuda/3d/mem3d.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_MEM3D_H -#define _CUDA_MEM3D_H - -#include - -#include "astra3d.h" - -namespace astra { -class CVolumeGeometry3D; -class CProjectionGeometry3D; -} - -namespace astraCUDA3d { - -// TODO: Make it possible to delete these handles when they're no longer -// necessary inside the FP/BP -// -// TODO: Add functions for querying capacity - -struct SMemHandle3D_internal; - -struct MemHandle3D { - boost::shared_ptr d; - operator bool() const { return (bool)d; } -}; - -struct SSubDimensions3D { - unsigned int nx; - unsigned int ny; - unsigned int nz; - unsigned int pitch; - unsigned int subnx; - unsigned int subny; - unsigned int subnz; - unsigned int subx; - unsigned int suby; - unsigned int subz; -}; - -/* -// Useful or not? -enum Mem3DCopyMode { - MODE_SET, - MODE_ADD -}; -*/ - -enum Mem3DZeroMode { - INIT_NO, - INIT_ZERO -}; - -int maxBlockDimension(); - -_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); - -MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero); - -bool copyToGPUMemory(const float *src, MemHandle3D dst, const SSubDimensions3D &pos); - -bool copyFromGPUMemory(float *dst, MemHandle3D src, const SSubDimensions3D &pos); - -bool freeGPUMemory(MemHandle3D handle); - -bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned int z); - -bool setGPUIndex(int index); - - -bool FP(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, int iDetectorSuperSampling, astra::Cuda3DProjectionKernel projKernel); - -bool BP(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, int iVoxelSuperSampling, bool bFDKWeighting); - -bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, bool bShortScan, const float *pfFilter = 0); - -} - -#endif diff --git a/cuda/3d/par3d_bp.cu b/cuda/3d/par3d_bp.cu index 6f76d22..3656f78 100644 --- a/cuda/3d/par3d_bp.cu +++ b/cuda/3d/par3d_bp.cu @@ -25,20 +25,20 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" + +#ifdef STANDALONE +#include "astra/cuda/3d/par3d_fp.h" +#include "testutil.h" +#endif + #include #include #include #include #include -#include "util3d.h" - -#ifdef STANDALONE -#include "par3d_fp.h" -#include "testutil.h" -#endif - -#include "dims3d.h" typedef texture texture3D; diff --git a/cuda/3d/par3d_bp.h b/cuda/3d/par3d_bp.h deleted file mode 100644 index b4ec6a3..0000000 --- a/cuda/3d/par3d_bp.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_PAR3D_BP_H -#define _CUDA_PAR3D_BP_H - -namespace astraCUDA3d { - -_AstraExport bool Par3DBP_Array(cudaPitchedPtr D_volumeData, - cudaArray *D_projArray, - const SDimensions3D& dims, const SPar3DProjection* angles, - const SProjectorParams3D& params); - -_AstraExport bool Par3DBP(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SPar3DProjection* angles, - const SProjectorParams3D& params); - - -} - -#endif diff --git a/cuda/3d/par3d_fp.cu b/cuda/3d/par3d_fp.cu index 8e2a2d0..515b1ba 100644 --- a/cuda/3d/par3d_fp.cu +++ b/cuda/3d/par3d_fp.cu @@ -25,19 +25,20 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/dims3d.h" + +#ifdef STANDALONE +#include "testutil.h" +#endif + + #include #include #include #include #include -#include "util3d.h" - -#ifdef STANDALONE -#include "testutil.h" -#endif - -#include "dims3d.h" typedef texture texture3D; diff --git a/cuda/3d/par3d_fp.h b/cuda/3d/par3d_fp.h deleted file mode 100644 index 18f5f2e..0000000 --- a/cuda/3d/par3d_fp.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_PAR3D_FP_H -#define _CUDA_PAR3D_FP_H - -namespace astraCUDA3d { - -_AstraExport bool Par3DFP_Array(cudaArray *D_volArray, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SPar3DProjection* angles, - const SProjectorParams3D& params); - -_AstraExport bool Par3DFP(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SPar3DProjection* angles, - const SProjectorParams3D& params); - -_AstraExport bool Par3DFP_SumSqW(cudaPitchedPtr D_volumeData, - cudaPitchedPtr D_projData, - const SDimensions3D& dims, const SPar3DProjection* angles, - const SProjectorParams3D& params); - -} - -#endif diff --git a/cuda/3d/sirt3d.cu b/cuda/3d/sirt3d.cu index 14f5768..332589e 100644 --- a/cuda/3d/sirt3d.cu +++ b/cuda/3d/sirt3d.cu @@ -25,18 +25,18 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ -#include -#include - -#include "sirt3d.h" -#include "util3d.h" -#include "arith3d.h" -#include "cone_fp.h" +#include "astra/cuda/3d/sirt3d.h" +#include "astra/cuda/3d/util3d.h" +#include "astra/cuda/3d/arith3d.h" +#include "astra/cuda/3d/cone_fp.h" #ifdef STANDALONE #include "testutil.h" #endif +#include +#include + namespace astraCUDA3d { SIRT::SIRT() : ReconAlgo3D() diff --git a/cuda/3d/sirt3d.h b/cuda/3d/sirt3d.h deleted file mode 100644 index 7c9a7c0..0000000 --- a/cuda/3d/sirt3d.h +++ /dev/null @@ -1,121 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_SIRT3D_H -#define _CUDA_SIRT3D_H - -#include "algo3d.h" - -namespace astraCUDA3d { - -class _AstraExport SIRT : public ReconAlgo3D { -public: - SIRT(); - ~SIRT(); - -// bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs); - - - bool enableVolumeMask(); - bool enableSinogramMask(); - - // init should be called after setting all geometry - bool init(); - - // Set relaxation factor. This may be called after init and before iterate. - void setRelaxation(float r) { fRelaxation = r; } - - // setVolumeMask should be called after init and before iterate, - // but only if enableVolumeMask was called before init. - // It may be called again after iterate. - bool setVolumeMask(cudaPitchedPtr& D_maskData); - - // setSinogramMask should be called after init and before iterate, - // but only if enableSinogramMask was called before init. - // It may be called again after iterate. - bool setSinogramMask(cudaPitchedPtr& D_smaskData); - - - // setBuffers should be called after init and before iterate. - // It may be called again after iterate. - bool setBuffers(cudaPitchedPtr& D_volumeData, - cudaPitchedPtr& D_projData); - - - // set Min/Max constraints. They may be called at any time, and will affect - // any iterate() calls afterwards. - bool setMinConstraint(float fMin); - bool setMaxConstraint(float fMax); - - // iterate should be called after init and setBuffers. - // It may be called multiple times. - bool iterate(unsigned int iterations); - - // Compute the norm of the difference of the FP of the current reconstruction - // and the sinogram. (This performs one FP.) - // It can be called after iterate. - float computeDiffNorm(); - -protected: - void reset(); - bool precomputeWeights(); - - bool useVolumeMask; - bool useSinogramMask; - - bool useMinConstraint; - bool useMaxConstraint; - float fMinConstraint; - float fMaxConstraint; - - float fRelaxation; - - cudaPitchedPtr D_maskData; - cudaPitchedPtr D_smaskData; - - // Input/output - cudaPitchedPtr D_sinoData; - cudaPitchedPtr D_volumeData; - - // Temporary buffers - cudaPitchedPtr D_projData; - cudaPitchedPtr D_tmpData; - - // Geometry-specific precomputed data - cudaPitchedPtr D_lineWeight; - cudaPitchedPtr D_pixelWeight; -}; - -bool doSIRT(cudaPitchedPtr D_volumeData, unsigned int volumePitch, - cudaPitchedPtr D_projData, unsigned int projPitch, - cudaPitchedPtr D_maskData, unsigned int maskPitch, - const SDimensions3D& dims, const SConeProjection* projs, - unsigned int iterations); - -} - -#endif diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index 1f436d8..90aa5ea 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -25,12 +25,14 @@ along with the ASTRA Toolbox. If not, see . ----------------------------------------------------------------------- */ +#include "astra/cuda/3d/util3d.h" + +#include "astra/cuda/2d/util.h" + +#include "astra/Logging.h" + #include #include -#include "util3d.h" -#include "../2d/util.h" - -#include "../../include/astra/Logging.h" namespace astraCUDA3d { diff --git a/cuda/3d/util3d.h b/cuda/3d/util3d.h deleted file mode 100644 index 17eb31e..0000000 --- a/cuda/3d/util3d.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec 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 . - ------------------------------------------------------------------------ -*/ - -#ifndef _CUDA_UTIL3D_H -#define _CUDA_UTIL3D_H - -#include -#include "dims3d.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#include "../2d/util.h" - -namespace astraCUDA3d { - -cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims); -cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims); -bool zeroVolumeData(cudaPitchedPtr& D_data, const SDimensions3D& dims); -bool zeroProjectionData(cudaPitchedPtr& D_data, const SDimensions3D& dims); -bool copyVolumeToDevice(const float* data, cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); -bool copyProjectionsToDevice(const float* data, cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); -bool copyVolumeFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); -bool copyProjectionsFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); -bool duplicateVolumeData(cudaPitchedPtr& D_dest, const cudaPitchedPtr& D_src, const SDimensions3D& dims); -bool duplicateProjectionData(cudaPitchedPtr& D_dest, const cudaPitchedPtr& D_src, const SDimensions3D& dims); - - -bool transferProjectionsToArray(cudaPitchedPtr D_projData, cudaArray* array, const SDimensions3D& dims); -bool transferVolumeToArray(cudaPitchedPtr D_volumeData, cudaArray* array, const SDimensions3D& dims); -bool zeroProjectionArray(cudaArray* array, const SDimensions3D& dims); -bool zeroVolumeArray(cudaArray* array, const SDimensions3D& dims); -cudaArray* allocateProjectionArray(const SDimensions3D& dims); -cudaArray* allocateVolumeArray(const SDimensions3D& dims); - -bool cudaTextForceKernelsCompletion(); - -float dotProduct3D(cudaPitchedPtr data, unsigned int x, unsigned int y, unsigned int z); - -int calcNextPowerOfTwo(int _iValue); - -} - -#endif diff --git a/include/astra/CudaFilteredBackProjectionAlgorithm.h b/include/astra/CudaFilteredBackProjectionAlgorithm.h index 5ff9f02..1280e9a 100644 --- a/include/astra/CudaFilteredBackProjectionAlgorithm.h +++ b/include/astra/CudaFilteredBackProjectionAlgorithm.h @@ -30,11 +30,11 @@ along with the ASTRA Toolbox. If not, see . #ifdef ASTRA_CUDA -#include -#include -#include +#include "Float32ProjectionData2D.h" +#include "Float32VolumeData2D.h" +#include "CudaReconstructionAlgorithm2D.h" -#include "../../cuda/2d/astra.h" +#include "cuda/2d/astra.h" namespace astra { diff --git a/include/astra/CudaProjector2D.h b/include/astra/CudaProjector2D.h index db6972e..8f61064 100644 --- a/include/astra/CudaProjector2D.h +++ b/include/astra/CudaProjector2D.h @@ -33,7 +33,7 @@ along with the ASTRA Toolbox. If not, see . #include "ParallelProjectionGeometry2D.h" #include "Float32Data2D.h" #include "Projector2D.h" -#include "../../cuda/2d/astra.h" +#include "cuda/2d/astra.h" namespace astra { diff --git a/include/astra/CudaProjector3D.h b/include/astra/CudaProjector3D.h index 83ce93e..60df7bb 100644 --- a/include/astra/CudaProjector3D.h +++ b/include/astra/CudaProjector3D.h @@ -36,7 +36,7 @@ along with the ASTRA Toolbox. If not, see . #include "Globals.h" #include "Config.h" #include "Projector3D.h" -#include "../../cuda/3d/astra3d.h" +#include "cuda/3d/astra3d.h" namespace astra { diff --git a/include/astra/Float32Data3D.h b/include/astra/Float32Data3D.h index 12ad685..1bdddc6 100644 --- a/include/astra/Float32Data3D.h +++ b/include/astra/Float32Data3D.h @@ -32,7 +32,7 @@ along with the ASTRA Toolbox. If not, see . #include "Float32Data.h" #include "Float32Data2D.h" -#include "../../cuda/3d/mem3d.h" +#include "cuda/3d/mem3d.h" namespace astra { diff --git a/include/astra/Float32Data3DGPU.h b/include/astra/Float32Data3DGPU.h index 9ebb341..cac38f6 100644 --- a/include/astra/Float32Data3DGPU.h +++ b/include/astra/Float32Data3DGPU.h @@ -33,7 +33,7 @@ along with the ASTRA Toolbox. If not, see . #include "Globals.h" #include "Float32Data3D.h" -#include "../../cuda/3d/mem3d.h" +#include "cuda/3d/mem3d.h" namespace astra { diff --git a/include/astra/cuda/2d/algo.h b/include/astra/cuda/2d/algo.h new file mode 100644 index 0000000..2ce929c --- /dev/null +++ b/include/astra/cuda/2d/algo.h @@ -0,0 +1,173 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ALGO_H +#define _CUDA_ALGO_H + +#include "astra/Globals.h" +#include "dims.h" + +namespace astra { + +class CParallelProjectionGeometry2D; +class CParallelVecProjectionGeometry2D; +class CFanFlatProjectionGeometry2D; +class CFanFlatVecProjectionGeometry2D; +class CVolumeGeometry2D; +class CProjectionGeometry2D; + +} + +namespace astraCUDA { + +class _AstraExport ReconAlgo { +public: + ReconAlgo(); + virtual ~ReconAlgo(); + + bool setGPUIndex(int iGPUIndex); + + bool setGeometry(const astra::CVolumeGeometry2D* pVolGeom, + const astra::CProjectionGeometry2D* pProjGeom); + + bool setSuperSampling(int raysPerDet, int raysPerPixelDim); + + void signalAbort() { shouldAbort = true; } + + virtual bool enableVolumeMask(); + virtual bool enableSinogramMask(); + + // init should be called after setting all geometry + virtual bool init() = 0; + + // setVolumeMask should be called after init and before iterate, + // but only if enableVolumeMask was called before init. + // It may be called again after iterate. + bool setVolumeMask(float* D_maskData, unsigned int maskPitch); + + // setSinogramMask should be called after init and before iterate, + // but only if enableSinogramMask was called before init. + // It may be called again after iterate. + bool setSinogramMask(float* D_smaskData, unsigned int smaskPitch); + + + // setBuffers should be called after init and before iterate. + // It may be called again after iterate. + virtual bool setBuffers(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch); + + + // instead of calling setBuffers, you can also call allocateBuffers + // to let ReconAlgo manage its own GPU memory + virtual bool allocateBuffers(); + + // copy data to GPU. This must be called after allocateBuffers. + // pfSinogram, pfReconstruction, pfVolMask, pfSinoMask are the + // sinogram, reconstruction, volume mask and sinogram mask in system RAM, + // respectively. The corresponding pitch variables give the pitches + // of these buffers, measured in floats. + // The sinogram is multiplied by fSinogramScale after uploading it. + virtual bool copyDataToGPU(const float* pfSinogram, unsigned int iSinogramPitch, float fSinogramScale, + const float* pfReconstruction, unsigned int iReconstructionPitch, + const float* pfVolMask, unsigned int iVolMaskPitch, + const float* pfSinoMask, unsigned int iSinoMaskPitch); + + + + // set Min/Max constraints. They may be called at any time, and will affect + // any iterate() calls afterwards. + virtual bool setMinConstraint(float fMin); + virtual bool setMaxConstraint(float fMax); + + + // iterate should be called after init and setBuffers. + // It may be called multiple times. + virtual bool iterate(unsigned int iterations) = 0; + + // Compute the norm of the difference of the FP of the current + // reconstruction and the sinogram. (This performs one FP.) + // It can be called after iterate. + virtual float computeDiffNorm() = 0; + // TODO: computeDiffNorm shouldn't be virtual, but for it to be + // implemented in ReconAlgo, it needs a way to get a suitable + // temporary sinogram buffer. + + bool getReconstruction(float* pfReconstruction, + unsigned int iReconstructionPitch) const; + + + +protected: + void reset(); + + bool callFP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + float outputScale); + bool callBP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + float outputScale); + + + SDimensions dims; + SParProjection* parProjs; + SFanProjection* fanProjs; + float fOutputScale; + + volatile bool shouldAbort; + + bool freeGPUMemory; + + // Input/output + float* D_sinoData; + unsigned int sinoPitch; + + float* D_volumeData; + unsigned int volumePitch; + + // Masks + bool useVolumeMask; + bool useSinogramMask; + + float* D_maskData; + unsigned int maskPitch; + float* D_smaskData; + unsigned int smaskPitch; + + // Min/max + bool useMinConstraint; + bool useMaxConstraint; + float fMinConstraint; + float fMaxConstraint; + + +}; + + +} + +#endif + diff --git a/include/astra/cuda/2d/arith.h b/include/astra/cuda/2d/arith.h new file mode 100644 index 0000000..e18bb1b --- /dev/null +++ b/include/astra/cuda/2d/arith.h @@ -0,0 +1,85 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ARITH_H +#define _CUDA_ARITH_H + +#include + +namespace astraCUDA { + + +struct opAddScaled; +struct opScaleAndAdd; +struct opAddMulScaled; +struct opAddMul; +struct opAdd; +struct opAdd2; +struct opMul; +struct opDiv; +struct opMul2; +struct opDividedBy; +struct opInvert; +struct opSet; +struct opClampMin; +struct opClampMax; +struct opClampMinMask; +struct opClampMaxMask; +struct opSegmentAndMask; +struct opSetMaskedValues; + +struct opMulMask; + + +template void processVolCopy(float* out, const SDimensions& dims); +template void processVolCopy(float* out, float param, const SDimensions& dims); +template void processVolCopy(float* out1, float* out2, float param1, float param2, const SDimensions& dims); +template void processVolCopy(float* out, const float* in, const SDimensions& dims); +template void processVolCopy(float* out, const float* in, float param, const SDimensions& dims); +template void processVolCopy(float* out, const float* in1, const float* in2, const SDimensions& dims); +template void processVolCopy(float* out, const float* in1, const float* in2, float param, const SDimensions& dims); + +template void processVol(float* out, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out, float fParam, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out1, float* out2, float fParam1, float fParam2, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out, const float* in, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out, const float* in, float fParam, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out, const float* in1, const float* in2, float fParam, unsigned int pitch, const SDimensions& dims); +template void processVol(float* out, const float* in1, const float* in2, unsigned int pitch, const SDimensions& dims); + +template void processSino(float* out, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out, float fParam, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out1, float* out2, float fParam1, float fParam2, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out, const float* in, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out, const float* in, float fParam, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out, const float* in1, const float* in2, float fParam, unsigned int pitch, const SDimensions& dims); +template void processSino(float* out, const float* in1, const float* in2, unsigned int pitch, const SDimensions& dims); + + +} + +#endif diff --git a/include/astra/cuda/2d/astra.h b/include/astra/cuda/2d/astra.h new file mode 100644 index 0000000..6f0e2f0 --- /dev/null +++ b/include/astra/cuda/2d/astra.h @@ -0,0 +1,127 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ASTRA_H +#define _CUDA_ASTRA_H + +#include "fbp_filters.h" +#include "dims.h" +#include "algo.h" + +using astraCUDA::SFanProjection; + +namespace astra { + +enum Cuda2DProjectionKernel { + ker2d_default = 0 +}; + +class CParallelProjectionGeometry2D; +class CParallelVecProjectionGeometry2D; +class CFanFlatProjectionGeometry2D; +class CFanFlatVecProjectionGeometry2D; +class CVolumeGeometry2D; +class CProjectionGeometry2D; + + +class _AstraExport BPalgo : public astraCUDA::ReconAlgo { +public: + BPalgo(); + ~BPalgo(); + + virtual bool init(); + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm(); +}; + + + + +// TODO: Clean up this interface to FP + +// Do a single forward projection +_AstraExport bool astraCudaFP(const float* pfVolume, float* pfSinogram, + unsigned int iVolWidth, unsigned int iVolHeight, + unsigned int iProjAngles, unsigned int iProjDets, + const SParProjection *pAngles, + unsigned int iDetSuperSampling = 1, + float fOutputScale = 1.0f, int iGPUIndex = 0); + +_AstraExport bool astraCudaFanFP(const float* pfVolume, float* pfSinogram, + unsigned int iVolWidth, unsigned int iVolHeight, + unsigned int iProjAngles, unsigned int iProjDets, + const SFanProjection *pAngles, + unsigned int iDetSuperSampling = 1, + float fOutputScale = 1.0f, int iGPUIndex = 0); + + +_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, + const CParallelProjectionGeometry2D* pProjGeom, + astraCUDA::SParProjection*& pProjs, + float& fOutputScale); + +_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, + const CParallelVecProjectionGeometry2D* pProjGeom, + astraCUDA::SParProjection*& pProjs, + float& fOutputScale); + + +_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, + const CFanFlatProjectionGeometry2D* pProjGeom, + astraCUDA::SFanProjection*& pProjs, + float& outputScale); + +_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, + const CFanFlatVecProjectionGeometry2D* pProjGeom, + astraCUDA::SFanProjection*& pProjs, + float& outputScale); + +_AstraExport bool convertAstraGeometry_dims(const CVolumeGeometry2D* pVolGeom, + const CProjectionGeometry2D* pProjGeom, + astraCUDA::SDimensions& dims); + +_AstraExport bool convertAstraGeometry(const CVolumeGeometry2D* pVolGeom, + const CProjectionGeometry2D* pProjGeom, + astraCUDA::SParProjection*& pParProjs, + astraCUDA::SFanProjection*& pFanProjs, + float& outputScale); +} + +namespace astraCUDA { + +// Return string with CUDA device number, name and memory size. +// Use device == -1 to get info for the current device. +_AstraExport std::string getCudaDeviceString(int device); + +_AstraExport bool setGPUIndex(int index); + +_AstraExport size_t availableGPUMemory(); + +} +#endif diff --git a/include/astra/cuda/2d/cgls.h b/include/astra/cuda/2d/cgls.h new file mode 100644 index 0000000..375a425 --- /dev/null +++ b/include/astra/cuda/2d/cgls.h @@ -0,0 +1,90 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_CGLS_H +#define _CUDA_CGLS_H + +#include "algo.h" + +namespace astraCUDA { + +class _AstraExport CGLS : public ReconAlgo { +public: + CGLS(); + virtual ~CGLS(); + + // disable some features + virtual bool enableSinogramMask() { return false; } + virtual bool setMinConstraint(float) { return false; } + virtual bool setMaxConstraint(float) { return false; } + + virtual bool init(); + + virtual bool setBuffers(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch); + + virtual bool copyDataToGPU(const float* pfSinogram, unsigned int iSinogramPitch, float fSinogramScale, + const float* pfReconstruction, unsigned int iReconstructionPitch, + const float* pfVolMask, unsigned int iVolMaskPitch, + const float* pfSinoMask, unsigned int iSinoMaskPitch); + + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm(); + +protected: + void reset(); + + bool sliceInitialized; + + // Buffers + float* D_r; + unsigned int rPitch; + + float* D_w; + unsigned int wPitch; + + float* D_z; + unsigned int zPitch; + + float* D_p; + unsigned int pPitch; + + + float gamma; +}; + + +_AstraExport bool doCGLS(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const float* angles, + const float* TOffsets, unsigned int iterations); + +} + +#endif diff --git a/include/astra/cuda/2d/darthelper.h b/include/astra/cuda/2d/darthelper.h new file mode 100644 index 0000000..3c2f83c --- /dev/null +++ b/include/astra/cuda/2d/darthelper.h @@ -0,0 +1,41 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ARITH2_H +#define _CUDA_ARITH2_H + +#include "astra/Globals.h" + +namespace astraCUDA { + + void roiSelect(float* out, float radius, unsigned int width, unsigned int height); + void dartMask(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, unsigned int width, unsigned int height); + void dartSmoothing(float* out, const float* in, float b, unsigned int radius, unsigned int width, unsigned int height); + +} + +#endif diff --git a/include/astra/cuda/2d/dims.h b/include/astra/cuda/2d/dims.h new file mode 100644 index 0000000..0bdefa9 --- /dev/null +++ b/include/astra/cuda/2d/dims.h @@ -0,0 +1,68 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_DIMS_H +#define _CUDA_DIMS_H + +#include "astra/GeometryUtil2D.h" + + +namespace astraCUDA { + +using astra::SParProjection; +using astra::SFanProjection; + + + +struct SDimensions { + // Width, height of reconstruction volume + unsigned int iVolWidth; + unsigned int iVolHeight; + + // Number of projection angles + unsigned int iProjAngles; + + // Number of detector pixels + unsigned int iProjDets; + + // in FP, number of rays to trace per detector pixel. + // This should usually be set to 1. + // If fDetScale > 1, this should be set to an integer of roughly + // the same size as fDetScale. + unsigned int iRaysPerDet; + + // in BP, square root of number of rays to trace per volume pixel + // This should usually be set to 1. + // If fDetScale < 1, this should be set to an integer of roughly + // the same size as 1 / fDetScale. + unsigned int iRaysPerPixelDim; +}; + +} + +#endif + diff --git a/include/astra/cuda/2d/em.h b/include/astra/cuda/2d/em.h new file mode 100644 index 0000000..3ffe01b --- /dev/null +++ b/include/astra/cuda/2d/em.h @@ -0,0 +1,75 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_EM_H +#define _CUDA_EM_H + +#include "algo.h" + +namespace astraCUDA { + +class _AstraExport EM : public ReconAlgo { +public: + EM(); + virtual ~EM(); + + // disable some features + virtual bool enableSinogramMask() { return false; } + virtual bool enableVolumeMask() { return false; } + virtual bool setMinConstraint(float) { return false; } + virtual bool setMaxConstraint(float) { return false; } + + virtual bool init(); + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm(); + +protected: + void reset(); + bool precomputeWeights(); + + // Temporary buffers + float* D_projData; + unsigned int projPitch; + + float* D_tmpData; + unsigned int tmpPitch; + + // Geometry-specific precomputed data + float* D_pixelWeight; + unsigned int pixelPitch; +}; + +_AstraExport bool doEM(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const float* angles, + const float* TOffsets, unsigned int iterations); + +} + +#endif diff --git a/include/astra/cuda/2d/fan_bp.h b/include/astra/cuda/2d/fan_bp.h new file mode 100644 index 0000000..22349b0 --- /dev/null +++ b/include/astra/cuda/2d/fan_bp.h @@ -0,0 +1,52 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_FAN_BP_H +#define _CUDA_FAN_BP_H + +namespace astraCUDA { + +_AstraExport bool FanBP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const SFanProjection* angles, + float fOutputScale); + +_AstraExport bool FanBP_SART(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + unsigned int angle, + const SDimensions& dims, const SFanProjection* angles, + float fOutputScale); + +_AstraExport bool FanBP_FBPWeighted(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const SFanProjection* angles, + float fOutputScale); + + +} + +#endif diff --git a/include/astra/cuda/2d/fan_fp.h b/include/astra/cuda/2d/fan_fp.h new file mode 100644 index 0000000..3e8f1e4 --- /dev/null +++ b/include/astra/cuda/2d/fan_fp.h @@ -0,0 +1,40 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_FAN_FP_H +#define _CUDA_FAN_FP_H + +namespace astraCUDA { + +_AstraExport bool FanFP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const SFanProjection* angles, + float outputScale); + +} + +#endif diff --git a/include/astra/cuda/2d/fbp.h b/include/astra/cuda/2d/fbp.h new file mode 100644 index 0000000..8666646 --- /dev/null +++ b/include/astra/cuda/2d/fbp.h @@ -0,0 +1,97 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#include "algo.h" +#include "fbp_filters.h" + +namespace astraCUDA { + +class _AstraExport FBP : public ReconAlgo { +public: + FBP(); + ~FBP(); + + virtual bool useSinogramMask() { return false; } + virtual bool useVolumeMask() { return false; } + + // Returns the required size of a filter in the fourier domain + // when multiplying it with the fft of the projection data. + // Its value is equal to the smallest power of two larger than + // or equal to twice the number of detectors in the spatial domain. + // + // _iDetectorCount is the number of detectors in the spatial domain. + static int calcFourierFilterSize(int _iDetectorCount); + + // Sets the filter type. Some filter types require the user to supply an + // array containing the filter. + // The number of elements in a filter in the fourier domain should be equal + // to the value returned by calcFourierFilterSize(). + // The following types require a filter: + // + // - FILTER_PROJECTION: + // The filter size should be equal to the output of + // calcFourierFilterSize(). The filtered sinogram is + // multiplied with the supplied filter. + // + // - FILTER_SINOGRAM: + // Same as FILTER_PROJECTION, but now the filter should contain a row for + // every projection direction. + // + // - FILTER_RPROJECTION: + // The filter should now contain one kernel (= ifft of filter), with the + // peak in the center. The filter width + // can be any value. If odd, the peak is assumed to be in the center, if + // even, it is assumed to be at floor(filter-width/2). + // + // - FILTER_RSINOGRAM + // Same as FILTER_RPROJECTION, but now the supplied filter should contain a + // row for every projection direction. + // + // A large number of other filters (FILTER_RAMLAK, FILTER_SHEPPLOGAN, + // FILTER_COSINE, FILTER_HAMMING, and FILTER_HANN) + // have a D variable, which gives the cutoff point in the frequency domain. + // Setting this value to 1.0 will include the whole filter + bool setFilter(astra::E_FBPFILTER _eFilter, + const float * _pfHostFilter = NULL, + int _iFilterWidth = 0, float _fD = 1.0f, float _fFilterParameter = -1.0f); + + bool setShortScan(bool ss) { m_bShortScan = ss; return true; } + + virtual bool init(); + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm() { return 0.0f; } // TODO + +protected: + void reset(); + + void* D_filter; // cufftComplex* + bool m_bShortScan; +}; + +} diff --git a/include/astra/cuda/2d/fbp_filters.h b/include/astra/cuda/2d/fbp_filters.h new file mode 100644 index 0000000..7c1121a --- /dev/null +++ b/include/astra/cuda/2d/fbp_filters.h @@ -0,0 +1,61 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef FBP_FILTERS_H +#define FBP_FILTERS_H + +namespace astra { + +enum E_FBPFILTER +{ + FILTER_NONE, //< no filter (regular BP) + FILTER_RAMLAK, //< default FBP filter + FILTER_SHEPPLOGAN, //< Shepp-Logan + FILTER_COSINE, //< Cosine + FILTER_HAMMING, //< Hamming filter + FILTER_HANN, //< Hann filter + FILTER_TUKEY, //< Tukey filter + FILTER_LANCZOS, //< Lanczos filter + FILTER_TRIANGULAR, //< Triangular filter + FILTER_GAUSSIAN, //< Gaussian filter + FILTER_BARTLETTHANN, //< Bartlett-Hann filter + FILTER_BLACKMAN, //< Blackman filter + FILTER_NUTTALL, //< Nuttall filter, continuous first derivative + FILTER_BLACKMANHARRIS, //< Blackman-Harris filter + FILTER_BLACKMANNUTTALL, //< Blackman-Nuttall filter + FILTER_FLATTOP, //< Flat top filter + FILTER_KAISER, //< Kaiser filter + FILTER_PARZEN, //< Parzen filter + FILTER_PROJECTION, //< all projection directions share one filter + FILTER_SINOGRAM, //< every projection direction has its own filter + FILTER_RPROJECTION, //< projection filter in real space (as opposed to fourier space) + FILTER_RSINOGRAM, //< sinogram filter in real space +}; + +} + +#endif /* FBP_FILTERS_H */ diff --git a/include/astra/cuda/2d/fft.h b/include/astra/cuda/2d/fft.h new file mode 100644 index 0000000..d36cae2 --- /dev/null +++ b/include/astra/cuda/2d/fft.h @@ -0,0 +1,72 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef FFT_H +#define FFT_H + +#include +#include + +#include "fbp_filters.h" + +namespace astraCUDA { + +bool allocateComplexOnDevice(int _iProjectionCount, + int _iDetectorCount, + cufftComplex ** _ppDevComplex); + +bool freeComplexOnDevice(cufftComplex * _pDevComplex); + +bool uploadComplexArrayToDevice(int _iProjectionCount, int _iDetectorCount, + cufftComplex * _pHostComplexSource, + cufftComplex * _pDevComplexTarget); + +bool runCudaFFT(int _iProjectionCount, const float * _pfDevRealSource, + int _iSourcePitch, int _iProjDets, + int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount, + cufftComplex * _pDevTargetComplex); + +bool runCudaIFFT(int _iProjectionCount, const cufftComplex* _pDevSourceComplex, + float * _pfRealTarget, + int _iTargetPitch, int _iProjDets, + int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); + +void applyFilter(int _iProjectionCount, int _iFreqBinCount, + cufftComplex * _pSinogram, cufftComplex * _pFilter); + +int calcFFTFourierSize(int _iFFTRealSize); + +void genFilter(astra::E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, + cufftComplex * _pFilter, int _iFFTRealDetectorCount, + int _iFFTFourierDetectorCount, float _fParameter = -1.0f); + +void genIdenFilter(int _iProjectionCount, cufftComplex * _pFilter, + int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); + +} + +#endif /* FFT_H */ diff --git a/include/astra/cuda/2d/par_bp.h b/include/astra/cuda/2d/par_bp.h new file mode 100644 index 0000000..c8dfab8 --- /dev/null +++ b/include/astra/cuda/2d/par_bp.h @@ -0,0 +1,47 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_PAR_BP_H +#define _CUDA_PAR_BP_H + +#include "dims.h" + +namespace astraCUDA { + +_AstraExport bool BP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const SParProjection* angles, + float fOutputScale); + +_AstraExport bool BP_SART(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + unsigned int angle, const SDimensions& dims, + const SParProjection* angles, float fOutputScale); + +} + +#endif diff --git a/include/astra/cuda/2d/par_fp.h b/include/astra/cuda/2d/par_fp.h new file mode 100644 index 0000000..62277a1 --- /dev/null +++ b/include/astra/cuda/2d/par_fp.h @@ -0,0 +1,40 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_PAR_FP_H +#define _CUDA_PAR_FP_H + +namespace astraCUDA { + +_AstraExport bool FP(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + const SDimensions& dims, const SParProjection* angles, + float fOutputScale); + +} + +#endif diff --git a/include/astra/cuda/2d/sart.h b/include/astra/cuda/2d/sart.h new file mode 100644 index 0000000..6c0e547 --- /dev/null +++ b/include/astra/cuda/2d/sart.h @@ -0,0 +1,87 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_SART_H +#define _CUDA_SART_H + +#include "algo.h" + +namespace astraCUDA { + +class _AstraExport SART : public ReconAlgo { +public: + SART(); + ~SART(); + + // disable some features + virtual bool enableSinogramMask() { return false; } + + virtual bool init(); + + virtual bool setProjectionOrder(int* projectionOrder, int projectionCount); + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm(); + + void setRelaxation(float r) { fRelaxation = r; } + +protected: + void reset(); + bool precomputeWeights(); + + bool callFP_SART(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + unsigned int angle, float outputScale); + bool callBP_SART(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + unsigned int angle, float outputScale); + + + // projection angle variables + bool customOrder; + int* projectionOrder; + int projectionCount; + int iteration; + + // Temporary buffers + float* D_projData; + unsigned int projPitch; + + float* D_tmpData; // Only used when there's a volume mask + unsigned int tmpPitch; + + // Geometry-specific precomputed data + float* D_lineWeight; + unsigned int linePitch; + + float fRelaxation; +}; + +} + +#endif diff --git a/include/astra/cuda/2d/sirt.h b/include/astra/cuda/2d/sirt.h new file mode 100644 index 0000000..434a07c --- /dev/null +++ b/include/astra/cuda/2d/sirt.h @@ -0,0 +1,96 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_SIRT_H +#define _CUDA_SIRT_H + +#include "algo.h" + +namespace astraCUDA { + +class _AstraExport SIRT : public ReconAlgo { +public: + SIRT(); + ~SIRT(); + + virtual bool init(); + + // Do optional long-object compensation. See the comments in sirt.cu. + // Call this after init(). It can not be used in combination with masks. + bool doSlabCorrections(); + + // Set min/max masks to existing GPU memory buffers + bool setMinMaxMasks(float* D_minMaskData, float* D_maxMaskData, + unsigned int pitch); + + // Set min/max masks from RAM buffers + bool uploadMinMaxMasks(const float* minMaskData, const float* maxMaskData, + unsigned int pitch); + + void setRelaxation(float r) { fRelaxation = r; } + + virtual bool iterate(unsigned int iterations); + + virtual float computeDiffNorm(); + +protected: + void reset(); + bool precomputeWeights(); + + // Temporary buffers + float* D_projData; + unsigned int projPitch; + + float* D_tmpData; + unsigned int tmpPitch; + + // Geometry-specific precomputed data + float* D_lineWeight; + unsigned int linePitch; + + float* D_pixelWeight; + unsigned int pixelPitch; + + // Masks + bool freeMinMaxMasks; + float* D_minMaskData; + unsigned int minMaskPitch; + float* D_maxMaskData; + unsigned int maxMaskPitch; + + float fRelaxation; +}; + +bool doSIRT(float* D_volumeData, unsigned int volumePitch, + float* D_projData, unsigned int projPitch, + float* D_maskData, unsigned int maskPitch, + const SDimensions& dims, const float* angles, + const float* TOffsets, unsigned int iterations); + +} + +#endif diff --git a/include/astra/cuda/2d/util.h b/include/astra/cuda/2d/util.h new file mode 100644 index 0000000..70e7c86 --- /dev/null +++ b/include/astra/cuda/2d/util.h @@ -0,0 +1,84 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_UTIL_H +#define _CUDA_UTIL_H + +#include +#include +#include + +#include "astra/Globals.h" + +#include "dims.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define ASTRA_CUDA_ASSERT(err) do { if (err != cudaSuccess) { astraCUDA::reportCudaError(err); assert(err == cudaSuccess); } } while(0) + + +namespace astraCUDA { + +bool copyVolumeToDevice(const float* in_data, unsigned int in_pitch, + const SDimensions& dims, + float* outD_data, unsigned int out_pitch); +bool copyVolumeFromDevice(float* out_data, unsigned int out_pitch, + const SDimensions& dims, + float* inD_data, unsigned int in_pitch); +bool copySinogramFromDevice(float* out_data, unsigned int out_pitch, + const SDimensions& dims, + float* inD_data, unsigned int in_pitch); +bool copySinogramToDevice(const float* in_data, unsigned int in_pitch, + const SDimensions& dims, + float* outD_data, unsigned int out_pitch); + +bool allocateVolume(float*& D_ptr, unsigned int width, unsigned int height, unsigned int& pitch); +void zeroVolume(float* D_data, unsigned int pitch, unsigned int width, unsigned int height); + +bool allocateVolumeData(float*& D_ptr, unsigned int& pitch, const SDimensions& dims); +bool allocateProjectionData(float*& D_ptr, unsigned int& pitch, const SDimensions& dims); +void zeroVolumeData(float* D_ptr, unsigned int pitch, const SDimensions& dims); +void zeroProjectionData(float* D_ptr, unsigned int pitch, const SDimensions& dims); + +void duplicateVolumeData(float* D_dst, float* D_src, unsigned int pitch, const SDimensions& dims); +void duplicateProjectionData(float* D_dst, float* D_src, unsigned int pitch, const SDimensions& dims); + + + +bool cudaTextForceKernelsCompletion(); +void reportCudaError(cudaError_t err); + + + +float dotProduct2D(float* D_data, unsigned int pitch, + unsigned int width, unsigned int height); + +} + +#endif diff --git a/include/astra/cuda/3d/algo3d.h b/include/astra/cuda/3d/algo3d.h new file mode 100644 index 0000000..f5fd207 --- /dev/null +++ b/include/astra/cuda/3d/algo3d.h @@ -0,0 +1,71 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ALGO_H +#define _CUDA_ALGO_H + +#include "dims3d.h" +#include "util3d.h" + +namespace astraCUDA3d { + +class _AstraExport ReconAlgo3D { +public: + ReconAlgo3D(); + ~ReconAlgo3D(); + + bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs, const SProjectorParams3D& params); + bool setPar3DGeometry(const SDimensions3D& dims, const SPar3DProjection* projs, const SProjectorParams3D& params); + + void signalAbort() { shouldAbort = true; } + +protected: + void reset(); + + bool callFP(cudaPitchedPtr& D_volumeData, + cudaPitchedPtr& D_projData, + float outputScale); + bool callBP(cudaPitchedPtr& D_volumeData, + cudaPitchedPtr& D_projData, + float outputScale); + + SDimensions3D dims; + SProjectorParams3D params; + SConeProjection* coneProjs; + SPar3DProjection* par3DProjs; + + float fOutputScale; + + volatile bool shouldAbort; + +}; + + +} + +#endif + diff --git a/include/astra/cuda/3d/arith3d.h b/include/astra/cuda/3d/arith3d.h new file mode 100644 index 0000000..fa9f3a1 --- /dev/null +++ b/include/astra/cuda/3d/arith3d.h @@ -0,0 +1,79 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ARITH3D_H +#define _CUDA_ARITH3D_H + +#include + +namespace astraCUDA3d { + +struct opAddScaled; +struct opScaleAndAdd; +struct opAddMulScaled; +struct opAddMul; +struct opAdd; +struct opMul; +struct opMul2; +struct opDividedBy; +struct opInvert; +struct opSet; +struct opClampMin; +struct opClampMax; + +enum VolType { + SINO = 0, + VOL = 1 +}; + + +template void processVol(CUdeviceptr* out, unsigned int pitch, unsigned int width, unsigned int height); +template void processVol(CUdeviceptr* out, float fParam, unsigned int pitch, unsigned int width, unsigned int height); +template void processVol(CUdeviceptr* out, const CUdeviceptr* in, unsigned int pitch, unsigned int width, unsigned int height); +template void processVol(CUdeviceptr* out, const CUdeviceptr* in, float fParam, unsigned int pitch, unsigned int width, unsigned int height); +template void processVol(CUdeviceptr* out, const CUdeviceptr* in1, const CUdeviceptr* in2, float fParam, unsigned int pitch, unsigned int width, unsigned int height); +template void processVol(CUdeviceptr* out, const CUdeviceptr* in1, const CUdeviceptr* in2, unsigned int pitch, unsigned int width, unsigned int height); + +template void processVol3D(cudaPitchedPtr& out, const SDimensions3D& dims); +template void processVol3D(cudaPitchedPtr& out, float fParam, const SDimensions3D& dims); +template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, const SDimensions3D& dims); +template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, float fParam, const SDimensions3D& dims); +template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, float fParam, const SDimensions3D& dims); +template void processVol3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, const SDimensions3D& dims); + +template void processSino3D(cudaPitchedPtr& out, const SDimensions3D& dims); +template void processSino3D(cudaPitchedPtr& out, float fParam, const SDimensions3D& dims); +template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, const SDimensions3D& dims); +template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in, float fParam, const SDimensions3D& dims); +template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, float fParam, const SDimensions3D& dims); +template void processSino3D(cudaPitchedPtr& out, const cudaPitchedPtr& in1, const cudaPitchedPtr& in2, const SDimensions3D& dims); + + + +} + +#endif diff --git a/include/astra/cuda/3d/astra3d.h b/include/astra/cuda/3d/astra3d.h new file mode 100644 index 0000000..0ea752d --- /dev/null +++ b/include/astra/cuda/3d/astra3d.h @@ -0,0 +1,314 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_ASTRA3D_H +#define _CUDA_ASTRA3D_H + +#include "dims3d.h" + +namespace astra { + + +// TODO: Switch to a class hierarchy as with the 2D algorithms + + +class CProjectionGeometry3D; +class CParallelProjectionGeometry3D; +class CParallelVecProjectionGeometry3D; +class CConeProjectionGeometry3D; +class CConeVecProjectionGeometry3D; +class CVolumeGeometry3D; +class AstraSIRT3d_internal; + +using astraCUDA3d::Cuda3DProjectionKernel; +using astraCUDA3d::ker3d_default; +using astraCUDA3d::ker3d_sum_square_weights; + + +class _AstraExport AstraSIRT3d { +public: + + AstraSIRT3d(); + ~AstraSIRT3d(); + + // Set the volume and projection geometry + bool setGeometry(const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom); + + // Enable supersampling. + // + // The number of rays used in FP is the square of iDetectorSuperSampling. + // The number of rays used in BP is the cube of iVoxelSuperSampling. + bool enableSuperSampling(unsigned int iVoxelSuperSampling, + unsigned int iDetectorSuperSampling); + + void setRelaxation(float r); + + // Enable volume/sinogram masks + // + // This may optionally be called before init(). + // If it is called, setVolumeMask()/setSinogramMask() must be called between + // setSinogram() and iterate(). + bool enableVolumeMask(); + bool enableSinogramMask(); + + // Set GPU index + // + // This should be called before init(). Note that setting the GPU index + // in a thread which has already used the GPU may not work. + bool setGPUIndex(int index); + + // Allocate GPU buffers and + // precompute geometry-specific data. + // + // This must be called after calling setReconstructionGeometry() and + // setProjectionGeometry() or setFanProjectionGeometry(). + bool init(); + + // Setup input sinogram for a slice. + // pfSinogram must be a float array of size XXX + // NB: iSinogramPitch is measured in floats, not in bytes. + // + // This must be called after init(), and before iterate(). It may be + // called again after iterate()/getReconstruction() to start a new slice. + // + // pfSinogram will only be read from during this call. + bool setSinogram(const float* pfSinogram, unsigned int iSinogramPitch); + + // Setup volume mask for a slice. + // pfMask must be a float array of size XXX + // NB: iMaskPitch is measured in floats, not in bytes. + // + // It may only contain the exact values 0.0f and 1.0f. Only volume pixels + // for which pfMask[z] is 1.0f are processed. + bool setVolumeMask(const float* pfMask, unsigned int iMaskPitch); + + // Setup sinogram mask for a slice. + // pfMask must be a float array of size XXX + // NB: iMaskPitch is measured in floats, not in bytes. + // + // It may only contain the exact values 0.0f and 1.0f. Only sinogram pixels + // for which pfMask[z] is 1.0f are processed. + bool setSinogramMask(const float* pfMask, unsigned int iMaskPitch); + + // Set the starting reconstruction for SIRT. + // pfReconstruction must be a float array of size XXX + // NB: iReconstructionPitch is measured in floats, not in bytes. + // + // This may be called between setSinogram() and iterate(). + // If this function is not called before iterate(), SIRT will start + // from a zero reconstruction. + // + // pfReconstruction will only be read from during this call. + bool setStartReconstruction(const float* pfReconstruction, + unsigned int iReconstructionPitch); + + // Enable min/max constraint. + // + // These may optionally be called between init() and iterate() + bool setMinConstraint(float fMin); + bool setMaxConstraint(float fMax); + + // Perform a number of (additive) SIRT iterations. + // This must be called after setSinogram(). + // + // If called multiple times, without calls to setSinogram() or + // setStartReconstruction() in between, iterate() will continue from + // the result of the previous call. + // Calls to getReconstruction() are allowed between calls to iterate() and + // do not change the state. + bool iterate(unsigned int iIterations); + + // Get the reconstructed slice. + // pfReconstruction must be a float array of size XXX + // NB: iReconstructionPitch is measured in floats, not in bytes. + // + // This may be called after iterate(). + bool getReconstruction(float* pfReconstruction, + unsigned int iReconstructionPitch) const; + + // Compute the norm of the difference of the FP of the current + // reconstruction and the sinogram. (This performs one FP.) + // It can be called after iterate(). + float computeDiffNorm(); + + // Signal the algorithm that it should abort after the current iteration. + // This is intended to be called from another thread. + void signalAbort(); + +protected: + AstraSIRT3d_internal *pData; +}; + + +class AstraCGLS3d_internal; + + +class _AstraExport AstraCGLS3d { +public: + + AstraCGLS3d(); + ~AstraCGLS3d(); + + // Set the volume and projection geometry + bool setGeometry(const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom); + + // Enable supersampling. + // + // The number of rays used in FP is the square of iDetectorSuperSampling. + // The number of rays used in BP is the cube of iVoxelSuperSampling. + bool enableSuperSampling(unsigned int iVoxelSuperSampling, + unsigned int iDetectorSuperSampling); + + // Enable volume/sinogram masks + // + // This may optionally be called before init(). + // If it is called, setVolumeMask()/setSinogramMask() must be called between + // setSinogram() and iterate(). + bool enableVolumeMask(); + //bool enableSinogramMask(); + + // Set GPU index + // + // This should be called before init(). Note that setting the GPU index + // in a thread which has already used the GPU may not work. + bool setGPUIndex(int index); + + // Allocate GPU buffers and + // precompute geometry-specific data. + // + // This must be called after calling setReconstructionGeometry() and + // setProjectionGeometry() or setFanProjectionGeometry(). + bool init(); + + // Setup input sinogram for a slice. + // pfSinogram must be a float array of size XXX + // NB: iSinogramPitch is measured in floats, not in bytes. + // + // This must be called after init(), and before iterate(). It may be + // called again after iterate()/getReconstruction() to start a new slice. + // + // pfSinogram will only be read from during this call. + bool setSinogram(const float* pfSinogram, unsigned int iSinogramPitch); + + // Setup volume mask for a slice. + // pfMask must be a float array of size XXX + // NB: iMaskPitch is measured in floats, not in bytes. + // + // It may only contain the exact values 0.0f and 1.0f. Only volume pixels + // for which pfMask[z] is 1.0f are processed. + bool setVolumeMask(const float* pfMask, unsigned int iMaskPitch); + + // Setup sinogram mask for a slice. + // pfMask must be a float array of size XXX + // NB: iMaskPitch is measured in floats, not in bytes. + // + // It may only contain the exact values 0.0f and 1.0f. Only sinogram pixels + // for which pfMask[z] is 1.0f are processed. + //bool setSinogramMask(const float* pfMask, unsigned int iMaskPitch); + + // Set the starting reconstruction for SIRT. + // pfReconstruction must be a float array of size XXX + // NB: iReconstructionPitch is measured in floats, not in bytes. + // + // This may be called between setSinogram() and iterate(). + // If this function is not called before iterate(), SIRT will start + // from a zero reconstruction. + // + // pfReconstruction will only be read from during this call. + bool setStartReconstruction(const float* pfReconstruction, + unsigned int iReconstructionPitch); + + // Enable min/max constraint. + // + // These may optionally be called between init() and iterate() + //bool setMinConstraint(float fMin); + //bool setMaxConstraint(float fMax); + + // Perform a number of (additive) SIRT iterations. + // This must be called after setSinogram(). + // + // If called multiple times, without calls to setSinogram() or + // setStartReconstruction() in between, iterate() will continue from + // the result of the previous call. + // Calls to getReconstruction() are allowed between calls to iterate() and + // do not change the state. + bool iterate(unsigned int iIterations); + + // Get the reconstructed slice. + // pfReconstruction must be a float array of size XXX + // NB: iReconstructionPitch is measured in floats, not in bytes. + // + // This may be called after iterate(). + bool getReconstruction(float* pfReconstruction, + unsigned int iReconstructionPitch) const; + + // Compute the norm of the difference of the FP of the current + // reconstruction and the sinogram. (This performs one FP.) + // It can be called after iterate(). + float computeDiffNorm(); + + // Signal the algorithm that it should abort after the current iteration. + // This is intended to be called from another thread. + void signalAbort(); + +protected: + AstraCGLS3d_internal *pData; +}; + +bool convertAstraGeometry_dims(const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom, + astraCUDA3d::SDimensions3D& dims); + +bool convertAstraGeometry(const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom, + SPar3DProjection*& pParProjs, + SConeProjection*& pConeProjs, + astraCUDA3d::SProjectorParams3D& params); + +_AstraExport bool astraCudaFP(const float* pfVolume, float* pfProjections, + const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom, + int iGPUIndex, int iDetectorSuperSampling, + Cuda3DProjectionKernel projKernel); + + +_AstraExport bool astraCudaBP(float* pfVolume, const float* pfProjections, + const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom, + int iGPUIndex, int iVoxelSuperSampling); + +_AstraExport bool astraCudaBP_SIRTWeighted(float* pfVolume, const float* pfProjections, + const CVolumeGeometry3D* pVolGeom, + const CProjectionGeometry3D* pProjGeom, + int iGPUIndex, int iVoxelSuperSampling); + +} + + +#endif diff --git a/include/astra/cuda/3d/cgls3d.h b/include/astra/cuda/3d/cgls3d.h new file mode 100644 index 0000000..b9b9e3a --- /dev/null +++ b/include/astra/cuda/3d/cgls3d.h @@ -0,0 +1,112 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_CGLS3D_H +#define _CUDA_CGLS3D_H + +#include "algo3d.h" + +namespace astraCUDA3d { + +class _AstraExport CGLS : public ReconAlgo3D { +public: + CGLS(); + ~CGLS(); + +// bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs); + + + bool enableVolumeMask(); + bool enableSinogramMask(); + + // init should be called after setting all geometry + bool init(); + + // setVolumeMask should be called after init and before iterate, + // but only if enableVolumeMask was called before init. + // It may be called again after iterate. + bool setVolumeMask(cudaPitchedPtr& D_maskData); + + // setSinogramMask should be called after init and before iterate, + // but only if enableSinogramMask was called before init. + // It may be called again after iterate. + bool setSinogramMask(cudaPitchedPtr& D_smaskData); + + + // setBuffers should be called after init and before iterate. + // It may be called again after iterate. + bool setBuffers(cudaPitchedPtr& D_volumeData, + cudaPitchedPtr& D_projData); + + + // set Min/Max constraints. They may be called at any time, and will affect + // any iterate() calls afterwards. + bool setMinConstraint(float fMin) { return false; } + bool setMaxConstraint(float fMax) { return false; } + + // iterate should be called after init and setBuffers. + // It may be called multiple times. + bool iterate(unsigned int iterations); + + // Compute the norm of the difference of the FP of the current reconstruction + // and the sinogram. (This performs one FP.) + // It can be called after iterate. + float computeDiffNorm(); + +protected: + void reset(); + + bool useVolumeMask; + bool useSinogramMask; + + cudaPitchedPtr D_maskData; + cudaPitchedPtr D_smaskData; + + // Input/output + cudaPitchedPtr D_sinoData; + cudaPitchedPtr D_volumeData; + + // Temporary buffers + cudaPitchedPtr D_r; + cudaPitchedPtr D_w; + cudaPitchedPtr D_z; + cudaPitchedPtr D_p; + + float gamma; + + bool sliceInitialized; +}; + +_AstraExport bool doCGLS(cudaPitchedPtr D_volumeData, unsigned int volumePitch, + cudaPitchedPtr D_projData, unsigned int projPitch, + cudaPitchedPtr D_maskData, unsigned int maskPitch, + const SDimensions3D& dims, const SConeProjection* projs, + unsigned int iterations); + +} + +#endif diff --git a/include/astra/cuda/3d/cone_bp.h b/include/astra/cuda/3d/cone_bp.h new file mode 100644 index 0000000..6dcadb1 --- /dev/null +++ b/include/astra/cuda/3d/cone_bp.h @@ -0,0 +1,45 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_CONE_BP_H +#define _CUDA_CONE_BP_H + +namespace astraCUDA3d { + +_AstraExport bool ConeBP_Array(cudaPitchedPtr D_volumeData, + cudaArray *D_projArray, + const SDimensions3D& dims, const SConeProjection* angles, + const SProjectorParams3D& params); + +_AstraExport bool ConeBP(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SConeProjection* angles, + const SProjectorParams3D& params); + +} + +#endif diff --git a/include/astra/cuda/3d/cone_fp.h b/include/astra/cuda/3d/cone_fp.h new file mode 100644 index 0000000..4da72d4 --- /dev/null +++ b/include/astra/cuda/3d/cone_fp.h @@ -0,0 +1,45 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_CONE_FP_H +#define _CUDA_CONE_FP_H + +namespace astraCUDA3d { + +_AstraExport bool ConeFP_Array(cudaArray *D_volArray, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SConeProjection* angles, + const SProjectorParams3D& params); + +_AstraExport bool ConeFP(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SConeProjection* angles, + const SProjectorParams3D& params); + +} + +#endif diff --git a/include/astra/cuda/3d/darthelper3d.h b/include/astra/cuda/3d/darthelper3d.h new file mode 100644 index 0000000..385e48e --- /dev/null +++ b/include/astra/cuda/3d/darthelper3d.h @@ -0,0 +1,42 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_DARTHELPER3_H +#define _CUDA_DARTHELPER3_H + +#include "dims3d.h" + +namespace astraCUDA3d { + + void dartSmoothing(float* out, const float* in, float b, unsigned int radius, SDimensions3D dims); + void dartMasking(float* out, const float* in, unsigned int conn, unsigned int radius, unsigned int threshold, SDimensions3D dims); + + bool setGPUIndex(int index); + +} + +#endif diff --git a/include/astra/cuda/3d/dims3d.h b/include/astra/cuda/3d/dims3d.h new file mode 100644 index 0000000..ef4ea78 --- /dev/null +++ b/include/astra/cuda/3d/dims3d.h @@ -0,0 +1,77 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_CONE_DIMS_H +#define _CUDA_CONE_DIMS_H + +#include "astra/GeometryUtil3D.h" + + +namespace astraCUDA3d { + +using astra::SConeProjection; +using astra::SPar3DProjection; + + +enum Cuda3DProjectionKernel { + ker3d_default = 0, + ker3d_sum_square_weights +}; + + +struct SDimensions3D { + unsigned int iVolX; + unsigned int iVolY; + unsigned int iVolZ; + unsigned int iProjAngles; + unsigned int iProjU; // number of detectors in the U direction + unsigned int iProjV; // number of detectors in the V direction +}; + +struct SProjectorParams3D { + SProjectorParams3D() : + iRaysPerDetDim(1), iRaysPerVoxelDim(1), + fOutputScale(1.0f), + fVolScaleX(1.0f), fVolScaleY(1.0f), fVolScaleZ(1.0f), + ker(ker3d_default), + bFDKWeighting(false) + { } + + unsigned int iRaysPerDetDim; + unsigned int iRaysPerVoxelDim; + float fOutputScale; + float fVolScaleX; + float fVolScaleY; + float fVolScaleZ; + Cuda3DProjectionKernel ker; + bool bFDKWeighting; +}; + +} + +#endif + diff --git a/include/astra/cuda/3d/fdk.h b/include/astra/cuda/3d/fdk.h new file mode 100644 index 0000000..6f6e73b --- /dev/null +++ b/include/astra/cuda/3d/fdk.h @@ -0,0 +1,50 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_FDK_H +#define _CUDA_FDK_H + +#include "dims3d.h" + +namespace astraCUDA3d { + +bool FDK_PreWeight(cudaPitchedPtr D_projData, + float fSrcOrigin, float fDetOrigin, + float fZShift, + float fDetUSize, float fDetVSize, float fVoxSize, + bool bShortScan, + const SDimensions3D& dims, const float* angles); + +bool FDK(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SConeProjection* angles, + const SDimensions3D& dims, SProjectorParams3D params, bool bShortScan, + const float* filter); + +} + +#endif diff --git a/include/astra/cuda/3d/mem3d.h b/include/astra/cuda/3d/mem3d.h new file mode 100644 index 0000000..78e1294 --- /dev/null +++ b/include/astra/cuda/3d/mem3d.h @@ -0,0 +1,105 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_MEM3D_H +#define _CUDA_MEM3D_H + +#include + +#include "astra3d.h" + +namespace astra { +class CVolumeGeometry3D; +class CProjectionGeometry3D; +} + +namespace astraCUDA3d { + +// TODO: Make it possible to delete these handles when they're no longer +// necessary inside the FP/BP +// +// TODO: Add functions for querying capacity + +struct SMemHandle3D_internal; + +struct MemHandle3D { + boost::shared_ptr d; + operator bool() const { return (bool)d; } +}; + +struct SSubDimensions3D { + unsigned int nx; + unsigned int ny; + unsigned int nz; + unsigned int pitch; + unsigned int subnx; + unsigned int subny; + unsigned int subnz; + unsigned int subx; + unsigned int suby; + unsigned int subz; +}; + +/* +// Useful or not? +enum Mem3DCopyMode { + MODE_SET, + MODE_ADD +}; +*/ + +enum Mem3DZeroMode { + INIT_NO, + INIT_ZERO +}; + +int maxBlockDimension(); + +_AstraExport MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch); + +MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero); + +bool copyToGPUMemory(const float *src, MemHandle3D dst, const SSubDimensions3D &pos); + +bool copyFromGPUMemory(float *dst, MemHandle3D src, const SSubDimensions3D &pos); + +bool freeGPUMemory(MemHandle3D handle); + +bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned int z); + +bool setGPUIndex(int index); + + +bool FP(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, int iDetectorSuperSampling, astra::Cuda3DProjectionKernel projKernel); + +bool BP(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, int iVoxelSuperSampling, bool bFDKWeighting); + +bool FDK(const astra::CProjectionGeometry3D* pProjGeom, MemHandle3D projData, const astra::CVolumeGeometry3D* pVolGeom, MemHandle3D volData, bool bShortScan, const float *pfFilter = 0); + +} + +#endif diff --git a/include/astra/cuda/3d/par3d_bp.h b/include/astra/cuda/3d/par3d_bp.h new file mode 100644 index 0000000..b4ec6a3 --- /dev/null +++ b/include/astra/cuda/3d/par3d_bp.h @@ -0,0 +1,46 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_PAR3D_BP_H +#define _CUDA_PAR3D_BP_H + +namespace astraCUDA3d { + +_AstraExport bool Par3DBP_Array(cudaPitchedPtr D_volumeData, + cudaArray *D_projArray, + const SDimensions3D& dims, const SPar3DProjection* angles, + const SProjectorParams3D& params); + +_AstraExport bool Par3DBP(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SPar3DProjection* angles, + const SProjectorParams3D& params); + + +} + +#endif diff --git a/include/astra/cuda/3d/par3d_fp.h b/include/astra/cuda/3d/par3d_fp.h new file mode 100644 index 0000000..18f5f2e --- /dev/null +++ b/include/astra/cuda/3d/par3d_fp.h @@ -0,0 +1,50 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_PAR3D_FP_H +#define _CUDA_PAR3D_FP_H + +namespace astraCUDA3d { + +_AstraExport bool Par3DFP_Array(cudaArray *D_volArray, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SPar3DProjection* angles, + const SProjectorParams3D& params); + +_AstraExport bool Par3DFP(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SPar3DProjection* angles, + const SProjectorParams3D& params); + +_AstraExport bool Par3DFP_SumSqW(cudaPitchedPtr D_volumeData, + cudaPitchedPtr D_projData, + const SDimensions3D& dims, const SPar3DProjection* angles, + const SProjectorParams3D& params); + +} + +#endif diff --git a/include/astra/cuda/3d/sirt3d.h b/include/astra/cuda/3d/sirt3d.h new file mode 100644 index 0000000..7c9a7c0 --- /dev/null +++ b/include/astra/cuda/3d/sirt3d.h @@ -0,0 +1,121 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_SIRT3D_H +#define _CUDA_SIRT3D_H + +#include "algo3d.h" + +namespace astraCUDA3d { + +class _AstraExport SIRT : public ReconAlgo3D { +public: + SIRT(); + ~SIRT(); + +// bool setConeGeometry(const SDimensions3D& dims, const SConeProjection* projs); + + + bool enableVolumeMask(); + bool enableSinogramMask(); + + // init should be called after setting all geometry + bool init(); + + // Set relaxation factor. This may be called after init and before iterate. + void setRelaxation(float r) { fRelaxation = r; } + + // setVolumeMask should be called after init and before iterate, + // but only if enableVolumeMask was called before init. + // It may be called again after iterate. + bool setVolumeMask(cudaPitchedPtr& D_maskData); + + // setSinogramMask should be called after init and before iterate, + // but only if enableSinogramMask was called before init. + // It may be called again after iterate. + bool setSinogramMask(cudaPitchedPtr& D_smaskData); + + + // setBuffers should be called after init and before iterate. + // It may be called again after iterate. + bool setBuffers(cudaPitchedPtr& D_volumeData, + cudaPitchedPtr& D_projData); + + + // set Min/Max constraints. They may be called at any time, and will affect + // any iterate() calls afterwards. + bool setMinConstraint(float fMin); + bool setMaxConstraint(float fMax); + + // iterate should be called after init and setBuffers. + // It may be called multiple times. + bool iterate(unsigned int iterations); + + // Compute the norm of the difference of the FP of the current reconstruction + // and the sinogram. (This performs one FP.) + // It can be called after iterate. + float computeDiffNorm(); + +protected: + void reset(); + bool precomputeWeights(); + + bool useVolumeMask; + bool useSinogramMask; + + bool useMinConstraint; + bool useMaxConstraint; + float fMinConstraint; + float fMaxConstraint; + + float fRelaxation; + + cudaPitchedPtr D_maskData; + cudaPitchedPtr D_smaskData; + + // Input/output + cudaPitchedPtr D_sinoData; + cudaPitchedPtr D_volumeData; + + // Temporary buffers + cudaPitchedPtr D_projData; + cudaPitchedPtr D_tmpData; + + // Geometry-specific precomputed data + cudaPitchedPtr D_lineWeight; + cudaPitchedPtr D_pixelWeight; +}; + +bool doSIRT(cudaPitchedPtr D_volumeData, unsigned int volumePitch, + cudaPitchedPtr D_projData, unsigned int projPitch, + cudaPitchedPtr D_maskData, unsigned int maskPitch, + const SDimensions3D& dims, const SConeProjection* projs, + unsigned int iterations); + +} + +#endif diff --git a/include/astra/cuda/3d/util3d.h b/include/astra/cuda/3d/util3d.h new file mode 100644 index 0000000..17eb31e --- /dev/null +++ b/include/astra/cuda/3d/util3d.h @@ -0,0 +1,68 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec 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 . + +----------------------------------------------------------------------- +*/ + +#ifndef _CUDA_UTIL3D_H +#define _CUDA_UTIL3D_H + +#include +#include "dims3d.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#include "../2d/util.h" + +namespace astraCUDA3d { + +cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims); +cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims); +bool zeroVolumeData(cudaPitchedPtr& D_data, const SDimensions3D& dims); +bool zeroProjectionData(cudaPitchedPtr& D_data, const SDimensions3D& dims); +bool copyVolumeToDevice(const float* data, cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); +bool copyProjectionsToDevice(const float* data, cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); +bool copyVolumeFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); +bool copyProjectionsFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch = 0); +bool duplicateVolumeData(cudaPitchedPtr& D_dest, const cudaPitchedPtr& D_src, const SDimensions3D& dims); +bool duplicateProjectionData(cudaPitchedPtr& D_dest, const cudaPitchedPtr& D_src, const SDimensions3D& dims); + + +bool transferProjectionsToArray(cudaPitchedPtr D_projData, cudaArray* array, const SDimensions3D& dims); +bool transferVolumeToArray(cudaPitchedPtr D_volumeData, cudaArray* array, const SDimensions3D& dims); +bool zeroProjectionArray(cudaArray* array, const SDimensions3D& dims); +bool zeroVolumeArray(cudaArray* array, const SDimensions3D& dims); +cudaArray* allocateProjectionArray(const SDimensions3D& dims); +cudaArray* allocateVolumeArray(const SDimensions3D& dims); + +bool cudaTextForceKernelsCompletion(); + +float dotProduct3D(cudaPitchedPtr data, unsigned int x, unsigned int y, unsigned int z); + +int calcNextPowerOfTwo(int _iValue); + +} + +#endif diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp index f57c0cd..2cc2be9 100644 --- a/matlab/mex/astra_mex_c.cpp +++ b/matlab/mex/astra_mex_c.cpp @@ -38,8 +38,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/AstraObjectManager.h" #ifdef ASTRA_CUDA -#include "../cuda/2d/astra.h" -#include "../cuda/2d/util.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/util.h" #include "astra/CompositeGeometryManager.h" #endif diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx index e7c5a6d..85a3b0c 100644 --- a/python/astra/astra_c.pyx +++ b/python/astra/astra_c.pyx @@ -41,7 +41,7 @@ cdef extern from "astra/Globals.h" namespace "astra": bool cudaAvailable() IF HAVE_CUDA==True: - cdef extern from "../cuda/2d/astra.h" namespace "astraCUDA": + cdef extern from "astra/cuda/2d/astra.h" namespace "astraCUDA": bool setGPUIndex(int) string getCudaDeviceString(int) ELSE: diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp index 0d536e6..8a4ce41 100644 --- a/src/CompositeGeometryManager.cpp +++ b/src/CompositeGeometryManager.cpp @@ -43,8 +43,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Float32VolumeData3DGPU.h" #include "astra/Logging.h" -#include "../cuda/2d/astra.h" -#include "../cuda/3d/mem3d.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/3d/mem3d.h" #include #include diff --git a/src/CudaBackProjectionAlgorithm.cpp b/src/CudaBackProjectionAlgorithm.cpp index 09a356a..c8d56f3 100644 --- a/src/CudaBackProjectionAlgorithm.cpp +++ b/src/CudaBackProjectionAlgorithm.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaBackProjectionAlgorithm.h" -#include "../cuda/2d/astra.h" +#include "astra/cuda/2d/astra.h" using namespace std; diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp index bfe0bcd..3fa19a1 100644 --- a/src/CudaBackProjectionAlgorithm3D.cpp +++ b/src/CudaBackProjectionAlgorithm3D.cpp @@ -38,7 +38,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/3d/astra3d.h" +#include "astra/cuda/3d/astra3d.h" using namespace std; diff --git a/src/CudaCglsAlgorithm.cpp b/src/CudaCglsAlgorithm.cpp index ec96991..bc60325 100644 --- a/src/CudaCglsAlgorithm.cpp +++ b/src/CudaCglsAlgorithm.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaCglsAlgorithm.h" -#include "../cuda/2d/cgls.h" +#include "astra/cuda/2d/cgls.h" using namespace std; diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp index 2ebc8a3..686c5b1 100644 --- a/src/CudaCglsAlgorithm3D.cpp +++ b/src/CudaCglsAlgorithm3D.cpp @@ -36,7 +36,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/3d/astra3d.h" +#include "astra/cuda/3d/astra3d.h" using namespace std; diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp index 5f9f67d..3c5519c 100644 --- a/src/CudaDartMaskAlgorithm.cpp +++ b/src/CudaDartMaskAlgorithm.cpp @@ -29,9 +29,9 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartMaskAlgorithm.h" -#include "../cuda/2d/astra.h" -#include "../cuda/2d/darthelper.h" -#include "../cuda/2d/algo.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/darthelper.h" +#include "astra/cuda/2d/algo.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaDartMaskAlgorithm3D.cpp b/src/CudaDartMaskAlgorithm3D.cpp index 2703981..7d9aed2 100644 --- a/src/CudaDartMaskAlgorithm3D.cpp +++ b/src/CudaDartMaskAlgorithm3D.cpp @@ -29,8 +29,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartMaskAlgorithm3D.h" -#include "../cuda/3d/darthelper3d.h" -#include "../cuda/3d/dims3d.h" +#include "astra/cuda/3d/darthelper3d.h" +#include "astra/cuda/3d/dims3d.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp index e3d569d..437680a 100644 --- a/src/CudaDartSmoothingAlgorithm.cpp +++ b/src/CudaDartSmoothingAlgorithm.cpp @@ -29,9 +29,9 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartSmoothingAlgorithm.h" -#include "../cuda/2d/astra.h" -#include "../cuda/2d/darthelper.h" -#include "../cuda/2d/algo.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/darthelper.h" +#include "astra/cuda/2d/algo.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaDartSmoothingAlgorithm3D.cpp b/src/CudaDartSmoothingAlgorithm3D.cpp index 26a379c..5903d3c 100644 --- a/src/CudaDartSmoothingAlgorithm3D.cpp +++ b/src/CudaDartSmoothingAlgorithm3D.cpp @@ -29,8 +29,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDartSmoothingAlgorithm3D.h" -#include "../cuda/3d/darthelper3d.h" -#include "../cuda/3d/dims3d.h" +#include "astra/cuda/3d/darthelper3d.h" +#include "astra/cuda/3d/dims3d.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp index 34c8a78..c48eedb 100644 --- a/src/CudaDataOperationAlgorithm.cpp +++ b/src/CudaDataOperationAlgorithm.cpp @@ -29,10 +29,10 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaDataOperationAlgorithm.h" -#include "../cuda/2d/algo.h" -#include "../cuda/2d/darthelper.h" -#include "../cuda/2d/astra.h" -#include "../cuda/2d/arith.h" +#include "astra/cuda/2d/algo.h" +#include "astra/cuda/2d/darthelper.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/arith.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaEMAlgorithm.cpp b/src/CudaEMAlgorithm.cpp index 43a1eb4..94e05a0 100644 --- a/src/CudaEMAlgorithm.cpp +++ b/src/CudaEMAlgorithm.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaEMAlgorithm.h" -#include "../cuda/2d/em.h" +#include "astra/cuda/2d/em.h" using namespace std; diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp index 6690401..4d8fc5a 100644 --- a/src/CudaFDKAlgorithm3D.cpp +++ b/src/CudaFDKAlgorithm3D.cpp @@ -36,9 +36,9 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/3d/astra3d.h" -#include "../cuda/2d/fft.h" -#include "../cuda/3d/util3d.h" +#include "astra/cuda/3d/astra3d.h" +#include "astra/cuda/2d/fft.h" +#include "astra/cuda/3d/util3d.h" using namespace std; using namespace astraCUDA3d; diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp index af9d55a..944f165 100644 --- a/src/CudaFilteredBackProjectionAlgorithm.cpp +++ b/src/CudaFilteredBackProjectionAlgorithm.cpp @@ -31,8 +31,8 @@ along with the ASTRA Toolbox. If not, see . #include "astra/AstraObjectManager.h" #include "astra/CudaProjector2D.h" -#include "../cuda/2d/astra.h" -#include "../cuda/2d/fbp.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/fbp.h" #include "astra/Logging.h" diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp index d1f6e96..5fb58a3 100644 --- a/src/CudaForwardProjectionAlgorithm.cpp +++ b/src/CudaForwardProjectionAlgorithm.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #ifdef ASTRA_CUDA -#include "../cuda/2d/astra.h" +#include "astra/cuda/2d/astra.h" #include #include diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp index 63b56f8..c70291e 100644 --- a/src/CudaForwardProjectionAlgorithm3D.cpp +++ b/src/CudaForwardProjectionAlgorithm3D.cpp @@ -41,7 +41,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/3d/astra3d.h" +#include "astra/cuda/3d/astra3d.h" using namespace std; diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp index e7e2ee1..cf7cb6a 100644 --- a/src/CudaReconstructionAlgorithm2D.cpp +++ b/src/CudaReconstructionAlgorithm2D.cpp @@ -36,7 +36,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/2d/algo.h" +#include "astra/cuda/2d/algo.h" #include diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp index 9a92e10..cccbbe7 100644 --- a/src/CudaRoiSelectAlgorithm.cpp +++ b/src/CudaRoiSelectAlgorithm.cpp @@ -29,9 +29,9 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaRoiSelectAlgorithm.h" -#include "../cuda/2d/astra.h" -#include "../cuda/2d/darthelper.h" -#include "../cuda/2d/algo.h" +#include "astra/cuda/2d/astra.h" +#include "astra/cuda/2d/darthelper.h" +#include "astra/cuda/2d/algo.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaSartAlgorithm.cpp b/src/CudaSartAlgorithm.cpp index fea987e..7c7ecc0 100644 --- a/src/CudaSartAlgorithm.cpp +++ b/src/CudaSartAlgorithm.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/CudaSartAlgorithm.h" -#include "../cuda/2d/sart.h" +#include "astra/cuda/2d/sart.h" using namespace std; diff --git a/src/CudaSirtAlgorithm.cpp b/src/CudaSirtAlgorithm.cpp index 3699d55..ae1b13d 100644 --- a/src/CudaSirtAlgorithm.cpp +++ b/src/CudaSirtAlgorithm.cpp @@ -31,7 +31,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/AstraObjectManager.h" -#include "../cuda/2d/sirt.h" +#include "astra/cuda/2d/sirt.h" using namespace std; diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp index b34b1e1..2483704 100644 --- a/src/CudaSirtAlgorithm3D.cpp +++ b/src/CudaSirtAlgorithm3D.cpp @@ -37,7 +37,7 @@ along with the ASTRA Toolbox. If not, see . #include "astra/Logging.h" -#include "../cuda/3d/astra3d.h" +#include "astra/cuda/3d/astra3d.h" using namespace std; diff --git a/src/Float32Data3D.cpp b/src/Float32Data3D.cpp index da053a3..078673d 100644 --- a/src/Float32Data3D.cpp +++ b/src/Float32Data3D.cpp @@ -29,7 +29,7 @@ along with the ASTRA Toolbox. If not, see . #include #ifdef ASTRA_CUDA -#include "../../cuda/3d/mem3d.h" +#include "astra/cuda/3d/mem3d.h" #endif using namespace std; diff --git a/src/Globals.cpp b/src/Globals.cpp index a04cc62..b983e3c 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -26,7 +26,7 @@ along with the ASTRA Toolbox. If not, see . */ #include "astra/Globals.h" -#include "../../cuda/2d/astra.h" +#include "astra/cuda/2d/astra.h" namespace astra { -- cgit v1.2.3