ANIMA  4.0
animaBaseTransformAgregator.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Transformation types handled, kind of redundant with itk transforms but much easier to use after
4 // TRANSLATION -> itk::TranslationTransform
5 // RIGID -> itk::Rigid3DTransform
6 // AFFINE -> itk::AffineTransform
7 
8 #include <itkMatrixOffsetTransformBase.h>
9 #include <itkImage.h>
10 #include <itkPoint.h>
11 
12 namespace anima
13 {
14 
15 template <unsigned int NDimensions = 3>
17 {
18 public:
19  typedef double ScalarType;
20  typedef double InternalScalarType;
21  typedef itk::Transform<InternalScalarType,NDimensions,NDimensions> BaseInputTransformType;
22  typedef typename BaseInputTransformType::Pointer BaseInputTransformPointer;
23  typedef itk::Transform<ScalarType,NDimensions,NDimensions> BaseOutputTransformType;
24  typedef itk::Point <InternalScalarType,NDimensions> PointType;
25  typedef itk::ImageRegion <NDimensions> RegionType;
26  typedef itk::Matrix <ScalarType,NDimensions,NDimensions> MatrixType;
27 
35  };
36 
38  virtual ~BaseTransformAgregator();
39 
40  void SetInputTransforms(std::vector <BaseInputTransformPointer> &inputTransforms);
41 
42  std::vector <BaseInputTransformPointer> &GetInputTransforms() {return m_InputTransforms;}
43  BaseInputTransformType *GetInputTransform(unsigned int i) {return m_InputTransforms[i].GetPointer();}
44 
45  void SetCurrentLinearTransform(BaseInputTransformPointer &inputTransforms);
46 
47  BaseInputTransformPointer &GetCurrentLinearTransform() { return m_CurrentLinearTransform; }
48 
49  void SetOrthogonalDirectionMatrix(const MatrixType &inputTransforms);
50 
51  MatrixType &GetOrthogonalDirectionMatrix() { return m_OrthogonalDirectionMatrix; }
52 
53  void SetInputOrigins(const std::vector <PointType> &inputOrigins)
54  {
55  m_InputOrigins = inputOrigins;
56  m_UpToDate = false;
57  }
58 
59  void SetInputRegions(const std::vector <RegionType> &inputRegions)
60  {
61  m_InputRegions = inputRegions;
62  m_UpToDate = false;
63  }
64 
65  std::vector <RegionType> & GetInputRegions() {return m_InputRegions;}
66  std::vector <PointType> & GetInputOrigins() {return m_InputOrigins;}
67  PointType & GetInputOrigin(unsigned int i) {return m_InputOrigins[i];}
68 
69  void SetInputWeights(const std::vector <InternalScalarType> &weights)
70  {
71  m_Weights = weights;
72  m_UpToDate = false;
73  }
74 
75  std::vector <InternalScalarType> & GetInputWeights() {return m_Weights;}
76  InternalScalarType GetInputWeight(unsigned int i) {return m_Weights[i];}
77  void SetInputWeight(unsigned int i, double w)
78  {
79  if (m_Weights.size() > i)
80  m_Weights[i] = w;
81  }
82 
85 
86  void SetUpToDate(bool value) {m_UpToDate = value;}
87 
88  void SetVerboseAgregation(bool value) {m_VerboseAgregation = value;}
89  bool GetVerboseAgregation() {return m_VerboseAgregation;}
90 
91  virtual PointType GetEstimationBarycenter() { return PointType(); }
92 
93  TRANSFORM_TYPE GetInputTransformType() {return m_InputTransformType;}
94  TRANSFORM_TYPE GetOutputTransformType() {return m_OutputTransformType;}
95 
96  virtual bool Update() = 0;
97 
98  BaseOutputTransformType *GetOutput();
99 
100 protected:
101  void SetOutput(BaseOutputTransformType *output);
102 
103 private:
104  std::vector <BaseInputTransformPointer> m_InputTransforms;
105  std::vector <PointType> m_InputOrigins;
106  std::vector <InternalScalarType> m_Weights;
107  BaseInputTransformPointer m_CurrentLinearTransform;
108  MatrixType m_OrthogonalDirectionMatrix;
109 
110  bool m_UpToDate;
111  bool m_VerboseAgregation;
112 
113  typename BaseOutputTransformType::Pointer m_Output;
114 
115  std::vector < RegionType > m_InputRegions;
116 
117  TRANSFORM_TYPE m_InputTransformType, m_OutputTransformType;
118 };
119 
120 } // end of namespace anima
121 
122 // Include instantiation
itk::Point< InternalScalarType, NDimensions > PointType
BaseInputTransformType * GetInputTransform(unsigned int i)
void SetInputTransforms(std::vector< BaseInputTransformPointer > &inputTransforms)
std::vector< BaseInputTransformPointer > & GetInputTransforms()
void SetCurrentLinearTransform(BaseInputTransformPointer &inputTransforms)
BaseInputTransformPointer & GetCurrentLinearTransform()
std::vector< RegionType > & GetInputRegions()
std::vector< InternalScalarType > & GetInputWeights()
void SetInputOrigins(const std::vector< PointType > &inputOrigins)
PointType & GetInputOrigin(unsigned int i)
void SetInputWeights(const std::vector< InternalScalarType > &weights)
itk::Transform< ScalarType, NDimensions, NDimensions > BaseOutputTransformType
itk::ImageRegion< NDimensions > RegionType
void SetOutputTransformType(TRANSFORM_TYPE name)
void SetInputWeight(unsigned int i, double w)
void SetOutput(BaseOutputTransformType *output)
void SetInputRegions(const std::vector< RegionType > &inputRegions)
void SetInputTransformType(TRANSFORM_TYPE name)
std::vector< PointType > & GetInputOrigins()
itk::Transform< InternalScalarType, NDimensions, NDimensions > BaseInputTransformType
BaseInputTransformType::Pointer BaseInputTransformPointer
itk::Matrix< ScalarType, NDimensions, NDimensions > MatrixType
InternalScalarType GetInputWeight(unsigned int i)
void SetOrthogonalDirectionMatrix(const MatrixType &inputTransforms)