NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Projection/itkForwardAndBackwardProjectionMatrix.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkForwardAndBackwardProjectionMatrix_h
16 #define itkForwardAndBackwardProjectionMatrix_h
17 
18 #include "itkRay.h"
19 #include <itkImage.h>
20 
21 #include <vnl/vnl_math.h>
22 #include <vnl/vnl_vector.h>
23 #include <vnl/vnl_sparse_matrix.h>
24 
25 #include "itkProjectionGeometry.h"
28 
29 namespace itk
30 {
31 
36  template <class TScalarType = double, class IntensityType = float>
37  class ITK_EXPORT ForwardAndBackwardProjectionMatrix : public Object
38  {
39  public:
42  typedef Object Superclass;
43  typedef SmartPointer<Self> Pointer;
44  typedef SmartPointer<const Self> ConstPointer;
45 
47  itkNewMacro(Self);
48 
50  itkTypeMacro(ForwardAndBackwardProjectionMatrix, Object);
51 
53  typedef typename itk::Size<3> VolumeSizeType;
54 
56  typedef typename InputImageType::Pointer InputImagePointer;
57  typedef typename InputImageType::ConstPointer InputImageConstPointer;
61  typedef typename InputImageType::SpacingType InputImageSpacingType;
62  typedef typename InputImageType::PointType InputImagePointType;
64 
66  typedef typename OutputImageType::Pointer OutputImagePointer;
67  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
71  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
72  typedef typename OutputImageType::PointType OutputImagePointType;
74 
77 
80 
83 
85  itkSetObjectMacro( ProjectionGeometry, ProjectionGeometryType );
86  itkGetObjectMacro( ProjectionGeometry, ProjectionGeometryType );
88  itkSetObjectMacro( AffineTransform, EulerAffineTransformType );
90  itkGetObjectMacro( AffineTransform, EulerAffineTransformType );
92  itkSetObjectMacro( PerspectiveTransform, PerspectiveProjectionTransformType );
94  itkGetObjectMacro( PerspectiveTransform, PerspectiveProjectionTransformType );
95 
96 
98  void SetProjectedImageSize(OutputImageSizeType &outImageSize) {m_OutputImageSize = outImageSize;};
100  void SetProjectedImageSpacing(OutputImageSpacingType &outImageSpacing) {
101  m_OutputImageSpacing = outImageSpacing;
102  this->GetOutput()->SetSpacing(m_OutputImageSpacing);
103  };
105  void SetProjectedImageOrigin(OutputImagePointType &outImageOrigin) {
106  m_OutputImageOrigin = outImageOrigin;
107  this->GetOutput()->SetOrigin(m_OutputImageOrigin);
108  };
109 
110 
112  typedef vnl_sparse_matrix<TScalarType> SparseMatrixType;
113  typedef vnl_matrix<TScalarType> FullMatrixType;
114  typedef vnl_vector<TScalarType> VectorType;
115 
117  void SetVolumeSize(const VolumeSizeType &r) {m_VolumeSize = r; m_FlagInitialised = false;}
118 
120  void GetForwardProjectionSparseMatrix(SparseMatrixType &R, InputImageConstPointer inImage, OutputImagePointer outImage,
121  VolumeSizeType &inSize, OutputImageSizeType &outSize, const unsigned int &projNum);
122 
124  void GetForwardProjectionSparseMatrix(SparseMatrixType &R, InputImagePointer inImage, OutputImagePointer outImage,
125  VolumeSizeType &inSize, OutputImageSizeType &outSize, const unsigned int &projNum);
126 
128  void GetBackwardProjectionSparseMatrix(SparseMatrixType &R, SparseMatrixType &RTrans,
129  VolumeSizeType &inSize, OutputImageSizeType &outSize, const unsigned int &projNum);
130 
132  void CalculteMatrixVectorMultiplication(SparseMatrixType &R, VectorType const &inputImageVector, VectorType &outputImageVector);
133 
134 
135  protected:
138  void PrintSelf(std::ostream& os, Indent indent) const;
139 
141  VolumeSizeType m_VolumeSize;
142  unsigned long int m_input3DImageTotalSize;
143  unsigned long int m_output2DImageTotalSize;
144 
147 
149  OutputImageSizeType m_OutputImageSize;
151  OutputImageSpacingType m_OutputImageSpacing;
153  OutputImagePointType m_OutputImageOrigin;
154 
156  double m_Threshold;
157 
159  ProjectionGeometryPointer m_ProjectionGeometry;
160 
163 
166 
172  typedef enum {
173  UNDEFINED_DIRECTION=0,
177  LAST_DIRECTION
178  } TraversalDirection;
179 
181  // SparseMatrixType const* pSparseForwardProjMatrix;
182 
184  // SparseMatrixType const* pSparseBackwardProjMatrix;
185 
186 
187  private:
188  ForwardAndBackwardProjectionMatrix(const Self&); //purposely not implemented
189  void operator=(const Self&); //purposely not implemented
190 
191  };
192 
193 } // end namespace itk
194 
195 #ifndef ITK_MANUAL_INSTANTIATION
196 #include "itkForwardAndBackwardProjectionMatrix.txx"
197 #endif
198 
199 #endif
void SetVolumeSize(const VolumeSizeType &r)
Set the volume size.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:117
InputImageType::PointType InputImagePointType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:62
void SetProjectedImageSize(OutputImageSizeType &outImageSize)
Set the size in pixels of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:98
OutputImageType::SizeType OutputImageSizeType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:70
SmartPointer< Self > Pointer
Definition: itkProjectionGeometry.h:36
OutputImageType::PointType OutputImagePointType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:72
void SetProjectedImageOrigin(OutputImagePointType &outImageOrigin)
Set the origin of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:105
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
double m_Threshold
The threshold above which voxels along the ray path are integrated.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:156
vnl_vector< TScalarType > VectorType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:114
OutputImageType::IndexType OutputImageIndexType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:73
void SetProjectedImageSpacing(OutputImageSpacingType &outImageSpacing)
Set the resolution in mm of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:100
Image< IntensityType, 3 > InputImageType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:55
itk::EulerAffineTransform< double, 3, 3 > EulerAffineTransformType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:78
Class to apply the affine transformation matrix to a 3D image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:37
Image< IntensityType, 2 > OutputImageType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:65
Definition: niftkITKAffineResampleImage.cxx:74
ProjectionGeometryType::Pointer ProjectionGeometryPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:76
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
ForwardAndBackwardProjectionMatrix Self
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:41
PerspectiveProjectionTransformType::Pointer m_PerspectiveTransform
The perspective transform.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:165
PerspectiveProjectionTransform of a vector space (e.g. space coordinates)
Definition: itkPerspectiveProjectionTransform.h:39
itk::Size< 3 > VolumeSizeType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:50
Euler Affine transform.
Definition: itkEulerAffineTransform.h:38
PerspectiveProjectionTransformType::Pointer PerspectiveProjectionTransformPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:82
Abstract class to calculate the geometry of a CT or tomo machine.
Definition: itkProjectionGeometry.h:29
OutputImageSizeType m_OutputImageSize
The size of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:149
x
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:174
InputImageType::IndexType InputImageIndexType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:63
ProjectionGeometryPointer m_ProjectionGeometry
The specific projection geometry to be used.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:159
InputImageType::Pointer InputImagePointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:56
OutputImageType::PixelType OutputImagePixelType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:69
InputImageType::PixelType InputImagePixelType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:59
OutputImageType::SpacingType OutputImageSpacingType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:71
Object Superclass
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:42
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
EulerAffineTransformType::Pointer EulerAffineTransformPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:79
z
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:176
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
SmartPointer< Self > Pointer
Definition: itkPerspectiveProjectionTransform.h:57
InputImageType::SpacingType InputImageSpacingType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:61
itk::PerspectiveProjectionTransform< double > PerspectiveProjectionTransformType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:81
y
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:175
itk::ProjectionGeometry< IntensityType > ProjectionGeometryType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:75
unsigned long int m_input3DImageTotalSize
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:142
OutputImageSpacingType m_OutputImageSpacing
The resolution of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:151
VolumeSizeType m_VolumeSize
A pointer to the 3D volume size.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:141
GLdouble GLdouble GLdouble r
Definition: glew.h:1390
InputImageType::RegionType InputImageRegionType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:58
OutputImageType::ConstPointer OutputImageConstPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:67
InputImageType::ConstPointer InputImageConstPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:57
unsigned long int m_output2DImageTotalSize
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:143
OutputImageType::Pointer OutputImagePointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:66
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
EulerAffineTransformType::Pointer m_AffineTransform
The affine transform.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:162
InputImageType::SizeType InputImageSizeType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:60
SmartPointer< const Self > ConstPointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:44
SmartPointer< Self > Pointer
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:43
bool m_FlagInitialised
Flag indicating whether the object has been initialised.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:146
OutputImageType::RegionType OutputImageRegionType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:68
OutputImagePointType m_OutputImageOrigin
The origin of the output projected image.
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:153
vnl_matrix< TScalarType > FullMatrixType
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:113
SmartPointer< Self > Pointer
Definition: itkEulerAffineTransform.h:49
virtual ~ForwardAndBackwardProjectionMatrix(void)
Definition: Projection/itkForwardAndBackwardProjectionMatrix.h:137