LCOV - code coverage report
Current view: top level - projectors - JosephsMethod.h (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 1 1 100.0 %
Date: 2022-05-27 02:48:28 Functions: 2 4 50.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "LinearOperator.h"
       4             : #include "Geometry.h"
       5             : #include "BoundingBox.h"
       6             : #include "VolumeDescriptor.h"
       7             : #include "DetectorDescriptor.h"
       8             : 
       9             : #include <vector>
      10             : #include <utility>
      11             : 
      12             : #include <Eigen/Geometry>
      13             : 
      14             : namespace elsa
      15             : {
      16             :     /**
      17             :      * @brief Operator representing the discretized X-ray transform in 2d/3d using Joseph's method.
      18             :      *
      19             :      * @author Christoph Hahn - initial implementation
      20             :      * @author Maximilian Hornung - modularization
      21             :      * @author Nikola Dinev - fixes
      22             :      *
      23             :      * @tparam data_t data type for the domain and range of the operator, defaulting to real_t
      24             :      *
      25             :      * The volume is traversed along the rays as specified by the Geometry. For interior voxels
      26             :      * the sampling point is located in the middle of the two planes orthogonal to the main
      27             :      * direction of the ray. For boundary voxels the sampling point is located at the center of the
      28             :      * ray intersection with the voxel.
      29             :      *
      30             :      * The geometry is represented as a list of projection matrices (see class Geometry), one for
      31             :      * each acquisition pose.
      32             :      *
      33             :      * Two modes of interpolation are available:
      34             :      * NN (NearestNeighbours) takes the value of the pixel/voxel containing the point
      35             :      * LINEAR performs linear interpolation for the nearest 2 pixels (in 2D)
      36             :      * or the nearest 4 voxels (in 3D).
      37             :      *
      38             :      * Forward projection is accomplished using apply(), backward projection using applyAdjoint().
      39             :      * This projector is matched.
      40             :      */
      41             :     template <typename data_t = real_t>
      42             :     class JosephsMethod : public LinearOperator<data_t>
      43             :     {
      44             :     public:
      45             :         /// Available interpolation modes
      46             :         enum class Interpolation { NN, LINEAR };
      47             : 
      48             :         /**
      49             :          * @brief Constructor for Joseph's traversal method.
      50             :          *
      51             :          * @param[in] domainDescriptor describing the domain of the operator (the volume)
      52             :          * @param[in] rangeDescriptor describing the range of the operator (the sinogram)
      53             :          * @param[in] interpolation enum specifying the interpolation mode
      54             :          *
      55             :          * The domain is expected to be 2 or 3 dimensional (volSizeX, volSizeY, [volSizeZ]),
      56             :          * the range is expected to be matching the domain (detSizeX, [detSizeY], acqPoses).
      57             :          */
      58             :         JosephsMethod(const VolumeDescriptor& domainDescriptor,
      59             :                       const DetectorDescriptor& rangeDescriptor,
      60             :                       Interpolation interpolation = Interpolation::LINEAR);
      61             : 
      62             :         /// default destructor
      63          84 :         ~JosephsMethod() = default;
      64             : 
      65             :     protected:
      66             :         /// default copy constructor, hidden from non-derived classes to prevent potential slicing
      67             :         JosephsMethod(const JosephsMethod<data_t>&) = default;
      68             : 
      69             :         /// apply Joseph's method (i.e. forward projection)
      70             :         void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override;
      71             : 
      72             :         /// apply the adjoint of Joseph's method (i.e. backward projection)
      73             :         void applyAdjointImpl(const DataContainer<data_t>& y,
      74             :                               DataContainer<data_t>& Aty) const override;
      75             : 
      76             :         /// implement the polymorphic clone operation
      77             :         JosephsMethod<data_t>* cloneImpl() const override;
      78             : 
      79             :         /// implement the polymorphic comparison operation
      80             :         bool isEqual(const LinearOperator<data_t>& other) const override;
      81             : 
      82             :     private:
      83             :         /// the bounding box of the volume
      84             :         BoundingBox _boundingBox;
      85             : 
      86             :         /// Reference to DetectorDescriptor stored in LinearOperator
      87             :         DetectorDescriptor& _detectorDescriptor;
      88             : 
      89             :         /// Reference to VolumeDescriptor stored in LinearOperator
      90             :         VolumeDescriptor& _volumeDescriptor;
      91             : 
      92             :         /// the interpolation mode
      93             :         Interpolation _interpolation;
      94             : 
      95             :         /// the traversal routine (for both apply/applyAdjoint)
      96             :         template <bool adjoint>
      97             :         void traverseVolume(const DataContainer<data_t>& vector,
      98             :                             DataContainer<data_t>& result) const;
      99             : 
     100             :         /**
     101             :          * @brief  Linear interpolation, works in any dimension
     102             :          *
     103             :          * @tparam adjoint true for backward projection, false for forward
     104             :          *
     105             :          * @param[in] vector the input DataContainer
     106             :          * @param[out] result DataContainer for results
     107             :          * @param[in] fractionals the fractional numbers used in the interpolation
     108             :          * @param[in] domainDim number of dimensions
     109             :          * @param[in] currentVoxel coordinates of voxel for interpolation
     110             :          * @param[in] intersection weighting for the interpolated values depending on the incidence
     111             :          * angle
     112             :          * @param[in] from index of the current vector position
     113             :          * @param[in] to index of the current result position
     114             :          * @param[in] mainDirection specifies the main direction of the ray
     115             :          */
     116             :         template <bool adjoint>
     117             :         void linear(const DataContainer<data_t>& vector, DataContainer<data_t>& result,
     118             :                     const RealVector_t& fractionals, index_t domainDim,
     119             :                     const IndexVector_t& currentVoxel, float intersection, index_t from, index_t to,
     120             :                     int mainDirection) const;
     121             : 
     122             :         /// lift from base class
     123             :         using LinearOperator<data_t>::_domainDescriptor;
     124             :         using LinearOperator<data_t>::_rangeDescriptor;
     125             :     };
     126             : } // namespace elsa

Generated by: LCOV version 1.15