Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
itkStatisticalModelTransformBase.h
1 /*
2  * This file is part of the statismo library.
3  *
4  * Author: Marcel Luethi (marcel.luethi@unibas.ch)
5  *
6  * Copyright (c) 2011 University of Basel
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the project's author nor the names of its
21  * contributors may be used to endorse or promote products derived from
22  * this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef __itkStatisticalModelTransform_h
39 #define __itkStatisticalModelTransform_h
40 
41 #include <iostream>
42 
43 #include <itkImage.h>
44 #include <itkTransform.h>
45 #include <itkVector.h>
46 
47 #include "Representer.h"
48 
49 #include "itkStatisticalModel.h"
50 
51 namespace itk {
52 
65 template <class TDataset, class TScalarType, unsigned int TInputDimension, unsigned int TOutputDimension = TInputDimension >
67  public itk::Transform< TScalarType , TInputDimension, TOutputDimension> {
68  public:
69  /* Standard class typedefs. */
71  typedef itk::Transform< TScalarType , TInputDimension, TOutputDimension> Superclass;
72  typedef SmartPointer<Self> Pointer;
73  typedef SmartPointer<const Self> ConstPointer;
74 
75  typedef vnl_vector<statismo::ScalarType> VectorType;
76  typedef vnl_matrix<statismo::ScalarType> MatrixType;
77 
78 
82  virtual void CopyBaseMembers(StatisticalModelTransformBase* another) const {
83  another->m_StatisticalModel = m_StatisticalModel;
84  another->m_coeff_vector = m_coeff_vector;
85  another->m_usedNumberCoefficients = m_usedNumberCoefficients;
86  another->m_FixedParameters = m_FixedParameters;
87  another->m_Parameters = this->m_Parameters;
88  }
89 
90 
92  itkTypeMacro( StatisticalModelTransformBase, Superclass );
93 
94  /* Dimension of parameters. */
95  itkStaticConstMacro(SpaceDimension, unsigned int, TInputDimension);
96  itkStaticConstMacro(InputSpaceDimension, unsigned int, TInputDimension);
97  itkStaticConstMacro(OutputSpaceDimension, unsigned int, TOutputDimension);
98 
99 
100  /* Parameters Type */
101  typedef typename Superclass::ParametersType ParametersType;
102  typedef typename Superclass::JacobianType JacobianType;
103  typedef typename Superclass::ScalarType ScalarType;
104  typedef typename Superclass::InputPointType InputPointType;
105  typedef typename Superclass::OutputPointType OutputPointType;
106  typedef typename Superclass::InputVectorType InputVectorType;
107  typedef typename Superclass::OutputVectorType OutputVectorType;
108  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
109  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
110  typedef typename Superclass::InputCovariantVectorType
111  InputCovariantVectorType;
112  typedef typename Superclass::OutputCovariantVectorType
113  OutputCovariantVectorType;
114 
115  typedef statismo::Representer<TDataset> RepresenterType;
117 
118 
119  virtual void ComputeJacobianWithRespectToParameters(const InputPointType &pt, JacobianType & jacobian) const;
120 
128  virtual OutputPointType TransformPoint(const InputPointType &pt) const = 0;
129 
133  virtual void SetIdentity(void);
134 
138  virtual void SetParameters( const ParametersType & );
139 
143  virtual const ParametersType& GetParameters(void) const;
144 
148  virtual void SetFixedParameters( const ParametersType &p ) {
149  // there no fixed parameters
150 
151  }
152 
156  virtual const ParametersType& GetFixedParameters(void) const {
157  return this->m_FixedParameters;
158  };
159 
164  virtual VectorType GetCoefficients() const {
165  return m_coeff_vector;
166  }
167 
172  virtual void SetCoefficients( VectorType& coefficients) {
173  m_coeff_vector = coefficients;
174  }
175 
179  void SetStatisticalModel(const StatisticalModelType* model);
180 
184  typename StatisticalModelType::ConstPointer GetStatisticalModel() const;
185 
191  void SetUsedNumberOfCoefficients(unsigned n) {
192  m_usedNumberCoefficients = n;
193  }
194 
199  return m_usedNumberCoefficients;
200  }
201 
202  protected:
203 
205  virtual ~StatisticalModelTransformBase() {};
206 
207  void PrintSelf(std::ostream &os, Indent indent) const;
208 
209  typename StatisticalModelType::ConstPointer m_StatisticalModel;
210  VectorType m_coeff_vector;
211  unsigned m_usedNumberCoefficients;
212  ParametersType m_FixedParameters;
213 
214  StatisticalModelTransformBase(const Self& obj);// : Superclass(obj) {} //purposely not implemented
215  void operator=(const Self& rhs);// { return Superclass::operator=(rhs); } //purposely not implemented
216 
217 
218 
219 };
220 
221 
222 } // namespace itk
223 
224 
225 #ifndef ITK_MANUAL_INSTANTIATION
226 # include "itkStatisticalModelTransformBase.hxx"
227 #endif
228 
229 #endif /* __itkStatisticalModelTransform_h */
virtual const ParametersType & GetFixedParameters(void) const
Definition: itkStatisticalModelTransformBase.h:156
virtual void CopyBaseMembers(StatisticalModelTransformBase *another) const
Definition: itkStatisticalModelTransformBase.h:82
A trivial representer, that does no representation at all, but works directly with vectorial data...
Definition: TrivialVectorialRepresenter.h:83
unsigned GetUsedNumberOfCoefficients()
Definition: itkStatisticalModelTransformBase.h:198
Base class that implements an itk transform interface for statistical models.
Definition: itkStatisticalModelTransformBase.h:66
virtual void SetFixedParameters(const ParametersType &p)
Definition: itkStatisticalModelTransformBase.h:148
virtual VectorType GetCoefficients() const
Definition: itkStatisticalModelTransformBase.h:164
void SetUsedNumberOfCoefficients(unsigned n)
Definition: itkStatisticalModelTransformBase.h:191
virtual void SetCoefficients(VectorType &coefficients)
Definition: itkStatisticalModelTransformBase.h:172
ITK Wrapper for the statismo::StatisticalModel class.
Definition: itkStatisticalModel.h:62