Orfeo Toolbox  3.16
itkActiveShapeModelCalculator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkActiveShapeModelCalculator.h,v $
5  Language: C++
6  Date: $Date: 2009-02-01 13:08:40 $
7  Version: $Revision: 1.2 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkActiveShapeModelCalculator_h
18 #define __itkActiveShapeModelCalculator_h
19 
20 #include <time.h>
21 #include <math.h>
22 
23 #include "vnl/vnl_vector.h"
24 #include "vnl/vnl_matrix.h"
25 #include "vnl/vnl_math.h"
26 #include "vnl/algo/vnl_matrix_inverse.h"
27 #include <vnl/algo/vnl_generalized_eigensystem.h>
28 #include <vnl/algo/vnl_symmetric_eigensystem.h>
29 
39 #include "itkPointSet.h"
40 #include "itkVector.h"
41 #include "itkListSample.h"
42 #include "itkExceptionObject.h"
43 
44 #include "itkConceptChecking.h"
45 
46 #include <vector>
47 #include <list>
48 
49 namespace itk {
50 
76 template < class TImage >
78 {
79 public:
82  typedef Object Superclass;
85 
87  itkNewMacro(Self);
88 
91 
97  typedef float PixelType;
98  typedef unsigned char Pixel8bitsType;
99 
104  typedef std::vector< unsigned int> VectorType;
106 
107 
112 
114  typedef TImage Image3DType;
118 
121  typedef typename Image3DType::IndexType Index3DType;
122 
125  typedef typename Image3DType::ConstPointer Image3DConstPointer;
126 
130 
134 
136  typedef std::list<IndexType> List2DType;
138 
145  typedef typename PointsContainer::Iterator PointsIterator;
146 
155 
157  virtual void SetImage( const Image3DType * image )
158  {
159  if ( m_Image != image )
160  {
161  m_Image = image;
162  this->Modified();
163  m_Valid = false;
164  }
165  }
166 
170  void SetLowerThresholdGradient(const double &lt)
171  { m_LowerThreshold = lt; }
172  const double &GetLowerThresholdGradient() const
173  { return m_LowerThreshold; }
174 
178  void SetUpperThresholdMeanDistance(const double &ut1)
179  { m_UpperThreshold1 = ut1; }
180  const double &GetUpperThresholdMeanDistance() const
181  { return m_UpperThreshold1; }
182 
186  void SetUpperThresholdDistance(const double &ut2)
187  { m_UpperThreshold2 = ut2; }
188  const double &GetUpperThresholdDistance() const
189  { return m_UpperThreshold2; }
190 
192  void SetTolerance(const double &t)
193  { m_Tolerance = t; }
194  const double &GetTolerance() const
195  { return m_Tolerance; }
196 
198  void SetPruneIteration(const unsigned int &t)
199  { m_PruneIteration = t; }
200  const unsigned int &GetPruneIteration() const
201  { return m_PruneIteration; }
202 
204  const unsigned int &GetNumberOfTrainingImages() const
205  { return m_NumberOfTrainingImages; }
206 
212  void GenerateData( );
213 
215  VectorOfDoubleType GetMeanShape();
216 
218  VectorOfDoubleType GetEigenvalues();
219 
221  MatrixOfDoubleType GetEigenvector();
222 
223 protected:
224 
225  ActiveShapeModelCalculator(): m_NumberOfTrainingImages(0)
226  {
227  m_LowerThreshold = 10.0; // default value
228  m_UpperThreshold1 = 1.0; // default value
229  m_UpperThreshold2 = 1.0; // default value
230  m_Tolerance = 2.0; // default value
231  m_PruneIteration = 3; // default value
232  m_NumberOfTrainingImages = 0;
233  m_EigenVectors.set_size(0,0);
234  m_EigenValues.set_size(0);
235  m_Means.set_size(0);
236  m_Valid = false;
237  m_Image = NULL;
238  }
239 
241 
242  void PrintSelf(std::ostream& os, Indent indent) const
243  {
244  Superclass::PrintSelf(os,indent);
245  os << indent << "LowerThreshold: " << m_LowerThreshold << std::endl;
246  os << indent << "UpperThreshold1: " << m_UpperThreshold1 << std::endl;
247  os << indent << "UpperThreshold2: " << m_UpperThreshold2 << std::endl;
248  os << indent << "Tolerance: " << m_Tolerance << std::endl;
249  os << indent << "Number of training images: " << m_NumberOfTrainingImages << std::endl;
250  os << indent << "Number of iteration for Prunig filter: " << m_PruneIteration << std::endl;
251  itkDebugMacro(<<" ");
252  itkDebugMacro(<<"Results of the shape model");
253  itkDebugMacro(<<"====================================");
254 
255  itkDebugMacro(<< "The mean shape: ");
256 
257  itkDebugMacro(<< m_Means);
258 
259  itkDebugMacro(<< " ");
260  itkDebugMacro(<< "================== ");
261 
262  itkDebugMacro(<< "The eigen values: ");
263 
264  itkDebugMacro(<< m_EigenValues);
265 
266  itkDebugMacro(<< " ");
267  itkDebugMacro(<< "================== ");
268 
269  itkDebugMacro(<< "The eigen vectors: ");
270 
271 
272  for(unsigned int i = 0; i < m_Means.size(); i++)
273  {
274  itkDebugMacro(<< m_EigenVectors.get_row(i));
275  }
276 
277  itkDebugMacro(<< " ");
278  itkDebugMacro(<< "+++++++++++++++++++++++++");
279  }// end PrintSelf
280 
281 
282 private:
283  ActiveShapeModelCalculator(const Self&); //purposely not implemented
284  void operator=(const Self&); //purposely not implemented
285 
286  bool m_Valid; // Have parameters been computed yet?
290  float m_Tolerance;
295  unsigned int m_PruneIteration;
297 
298 }; // class ActiveShapeModelCalculator
299 
300 } // end of namespace itk
301 
302 #ifndef ITK_MANUAL_INSTANTIATION
304 #endif
305 
306 #endif

Generated at Sat Feb 2 2013 23:23:07 for Orfeo Toolbox with doxygen 1.8.1.1