Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
itkStatisticalDeformationModelTransform.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 __ItkStatisticalDeformationModelTransform
39 #define __ItkStatisticalDeformationModelTransform
40 
41 #include <iostream>
42 
43 #include <itkImage.h>
44 #include <itkVector.h>
45 
46 #include "itkStandardImageRepresenter.h"
47 #include "itkStatisticalModel.h"
48 #include "itkStatisticalModelTransformBase.h"
49 
50 namespace itk {
51 
59 template <class TDataSet, class TScalarType, unsigned int TDimension >
61  public itk::StatisticalModelTransformBase< TDataSet, TScalarType , TDimension> {
62 
63  public:
64  /* Standard class typedefs. */
67  typedef SmartPointer<Self> Pointer;
68  typedef SmartPointer<const Self> ConstPointer;
69 
70  itkSimpleNewMacro( Self );
71 
74 
75  typedef typename Superclass::InputPointType InputPointType;
76  typedef typename Superclass::OutputPointType OutputPointType;
77  typedef typename Superclass::RepresenterType RepresenterType;
78 
82  virtual ::itk::LightObject::Pointer CreateAnother() const {
83  ::itk::LightObject::Pointer smartPtr;
84  Pointer another = Self::New().GetPointer();
85  this->CopyBaseMembers(another);
86 
87  smartPtr = static_cast<Pointer>(another);
88  return smartPtr;
89  }
90 
91 
99  virtual OutputPointType TransformPoint(const InputPointType &pt) const {
100  typename RepresenterType::ValueType d;
101  try {
102  d = this->m_StatisticalModel->DrawSampleAtPoint(this->m_coeff_vector, pt);
103  } catch (ExceptionObject &e) {
104  std::cout << "exception occured at point " << pt << std::endl;
105  std::cout << "message " << e.what() << std::endl;
106  }
107  OutputPointType transformedPoint;
108  for (unsigned i = 0; i < pt.GetPointDimension(); i++) {
109  transformedPoint[i] = pt[i] + d[i];
110  }
111  return transformedPoint;
112  }
113 
115 
116  StatisticalDeformationModelTransform() {}
117 
118  private:
119 
120 
121  StatisticalDeformationModelTransform(const StatisticalDeformationModelTransform& orig); // purposely not implemented
122  StatisticalDeformationModelTransform& operator=(const StatisticalDeformationModelTransform& rhs); //purposely not implemented
123 };
124 
125 
126 } // namespace itk
127 
128 #endif // __ItkStatisticalDeformationModelTransform
virtual OutputPointType TransformPoint(const InputPointType &pt) const
Definition: itkStatisticalDeformationModelTransform.h:99
An itk transform that allows for deformations defined by a given Statistical Deformation Model...
Definition: itkStatisticalDeformationModelTransform.h:60
virtual ::itk::LightObject::Pointer CreateAnother() const
Definition: itkStatisticalDeformationModelTransform.h:82
Base class that implements an itk transform interface for statistical models.
Definition: itkStatisticalModelTransformBase.h:66