/*! \file CPUStackResampler.h \brief Contains declaration of a class for spline/tri-linear resampling of irregularly sampled columns in the z-direction. \author Jesper Andersson \version 1.0b, May, 2021. */ // // CPUStackResampler.h // // Jesper Andersson, FMRIB Image Analysis Group // // Copyright (C) 2021 University of Oxford // #ifndef CPUStackResampler_h #define CPUStackResampler_h #include #include #include #include "newimage/newimageall.h" #include "EddyHelperClasses.h" namespace EDDY { class CPUStackResampler { public: /// Constructor. Performs the actual work so that when the object is created there is already a resampled image ready. /// This version of the constructor uses a predicted volume and the laplacian for regularisation CPUStackResampler(const NEWIMAGE::volume& stack, const NEWIMAGE::volume& zcoord, const NEWIMAGE::volume& pred, const NEWIMAGE::volume& mask, double lambda=0.005); /// This version of the constructor uses either splines and Laplacian regularisation or linear interpolation. CPUStackResampler(const NEWIMAGE::volume& stack, const NEWIMAGE::volume& zcoord, const NEWIMAGE::volume& mask, NEWIMAGE::interpolation interp=NEWIMAGE::spline, double lambda=0.005); ~CPUStackResampler() {} // Returns interpolated image const NEWIMAGE::volume& GetImage() const EddyTry { return(_ovol); } EddyCatch // Returns mask const NEWIMAGE::volume& GetMask() const EddyTry { return(_omask); } EddyCatch private: NEWIMAGE::volume _ovol; NEWIMAGE::volume _omask; void spline_interpolate_slice_stack(// Input const NEWIMAGE::volume& slice_stack, const NEWIMAGE::volume& z_coord, const NEWIMAGE::volume& stack_mask, double lambda, // Optional input const NEWIMAGE::volume *pred_ptr, // Output NEWIMAGE::volume& ovol, NEWIMAGE::volume& omask); void linear_interpolate_slice_stack(// Input const NEWIMAGE::volume& slice_stack, const NEWIMAGE::volume& z_coord, const NEWIMAGE::volume& stack_mask, // Output NEWIMAGE::volume& ovol, NEWIMAGE::volume& omask); arma::Mat get_StS(int sz, float lambda) const; arma::Mat get_regular_W(int sz) const; arma::Mat get_Wir(const NEWIMAGE::volume& zcoord, int i, int j) const; arma::Col get_y(const NEWIMAGE::volume& stack, int i, int j) const EddyTry { arma::Col y(stack.zsize()); for (int k=0; k sort_zcoord(const NEWIMAGE::volume& zcoord, int i, int j) const; arma::Mat get_prediction_weights(const std::vector zcoord) const; }; } // End namespace EDDY #endif // End #ifndef CPUStackResampler_h