go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkStatisticalShapePointPenalty.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 #ifndef __itkStatisticalShapePointPenalty_h
15 #define __itkStatisticalShapePointPenalty_h
16 
18 
19 #include "itkPoint.h"
20 #include "itkPointSet.h"
21 #include "itkImage.h"
22 #include "itkArray.h"
23 #include <itkVariableSizeMatrix.h>
24 
25 #include <vnl/vnl_matrix.h>
26 #include <vnl/vnl_math.h>
27 #include <vnl/vnl_vector.h>
28 #include <vnl/algo/vnl_real_eigensystem.h>
29 #include <vnl/algo/vnl_symmetric_eigensystem.h>
30 //#include <vnl/algo/vnl_svd.h>
31 #include <vnl/algo/vnl_svd_economy.h>
32 
33 #include <vcl_iostream.h>
34 #include <string>
35 
36 namespace itk
37 {
52 template< class TFixedPointSet, class TMovingPointSet >
54  public SingleValuedPointSetToPointSetMetric< TFixedPointSet, TMovingPointSet >
55 {
56 public:
57 
61  TFixedPointSet, TMovingPointSet > Superclass;
62  typedef SmartPointer< Self > Pointer;
63  typedef SmartPointer< const Self > ConstPointer;
64 
66  itkNewMacro( Self );
67 
69  itkTypeMacro( StatisticalShapePointPenalty,
71 
78 
86 
89 
92 
93  typedef typename OutputPointType::CoordRepType CoordRepType;
95  typedef vnl_matrix< CoordRepType > VnlMatrixType;
96  //typedef itk::Array<VnlVectorType *> ProposalDerivativeType;
97  typedef typename std::vector< VnlVectorType * > ProposalDerivativeType;
98  //typedef typename vnl_vector<VnlVectorType *> ProposalDerivativeType; //Cannot be linked
99  typedef vnl_svd_economy< CoordRepType > PCACovarianceType;
100 
102  void Initialize( void ) throw ( ExceptionObject );
103 
105  MeasureType GetValue( const TransformParametersType & parameters ) const;
106 
108  void GetDerivative( const TransformParametersType & parameters,
109  DerivativeType & Derivative ) const;
110 
112  void GetValueAndDerivative( const TransformParametersType & parameters,
113  MeasureType & Value, DerivativeType & Derivative ) const;
114 
116  itkSetClampMacro( ShrinkageIntensity, MeasureType, 0.0, 1.0 );
117  itkGetMacro( ShrinkageIntensity, MeasureType );
118 
119  itkSetMacro( ShrinkageIntensityNeedsUpdate, bool );
120  itkBooleanMacro( ShrinkageIntensityNeedsUpdate );
121 
123  itkSetClampMacro( BaseVariance, MeasureType,
124  -1.0, NumericTraits< MeasureType >::max() );
125  itkGetMacro( BaseVariance, MeasureType );
126 
127  itkSetMacro( BaseVarianceNeedsUpdate, bool );
128  itkBooleanMacro( BaseVarianceNeedsUpdate );
129 
130  itkSetClampMacro( CentroidXVariance, MeasureType,
131  -1.0, NumericTraits< MeasureType >::max() );
132  itkGetMacro( CentroidXVariance, MeasureType );
133 
134  itkSetClampMacro( CentroidYVariance, MeasureType,
135  -1.0, NumericTraits< MeasureType >::max() );
136  itkGetMacro( CentroidYVariance, MeasureType );
137 
138  itkSetClampMacro( CentroidZVariance, MeasureType,
139  -1.0, NumericTraits< MeasureType >::max() );
140  itkGetMacro( CentroidZVariance, MeasureType );
141 
142  itkSetClampMacro( SizeVariance, MeasureType,
143  -1.0, NumericTraits< MeasureType >::max() );
144  itkGetMacro( SizeVariance, MeasureType );
145 
146  itkSetMacro( VariancesNeedsUpdate, bool );
147  itkBooleanMacro( VariancesNeedsUpdate );
148 
149  itkSetClampMacro( CutOffValue, MeasureType,
150  0.0, NumericTraits< MeasureType >::max() );
151  itkGetMacro( CutOffValue, MeasureType );
152 
153  itkSetClampMacro( CutOffSharpness, MeasureType,
154  NumericTraits< MeasureType >::NonpositiveMin(), NumericTraits< MeasureType >::max() );
155  itkGetMacro( CutOffSharpness, MeasureType );
156 
157  itkSetMacro( ShapeModelCalculation, int );
158  itkGetConstReferenceMacro( ShapeModelCalculation, int );
159 
160  itkSetMacro( NormalizedShapeModel, bool );
161  itkGetConstReferenceMacro( NormalizedShapeModel, bool );
162  itkBooleanMacro( NormalizedShapeModel );
163 
164  itkSetConstObjectMacro( EigenVectors, vnl_matrix< double > );
165  itkSetConstObjectMacro( EigenValues, vnl_vector< double > );
166  itkSetConstObjectMacro( MeanVector, vnl_vector< double > );
167 
168  itkSetConstObjectMacro( CovarianceMatrix, vnl_matrix< double > );
169 
170 protected:
171 
173  virtual ~StatisticalShapePointPenalty();
174 
176  void PrintSelf( std::ostream & os, Indent indent ) const;
177 
178 private:
179 
180  StatisticalShapePointPenalty( const Self & ); // purposely not implemented
181  void operator=( const Self & ); // purposely not implemented
182 
183  void FillProposalVector( const OutputPointType & fixedPoint,
184  const unsigned int vertexindex ) const;
185 
186  void FillProposalDerivative( const OutputPointType & fixedPoint,
187  const unsigned int vertexindex ) const;
188 
190  const unsigned int shapeLength ) const;
191 
193  const unsigned int shapeLength ) const;
194 
195  void UpdateL2( const unsigned int shapeLength ) const;
196 
197  void NormalizeProposalVector( const unsigned int shapeLength ) const;
198 
199  void UpdateL2AndNormalizeProposalDerivative( const unsigned int shapeLength ) const;
200 
201  void CalculateValue( MeasureType & value, VnlVectorType & differenceVector,
202  VnlVectorType & centerrotated, VnlVectorType & eigrot ) const;
203 
204  void CalculateDerivative( DerivativeType & derivative, const MeasureType & value,
205  const VnlVectorType & differenceVector, const VnlVectorType & centerrotated,
206  const VnlVectorType & eigrot, const unsigned int shapeLength ) const;
207 
208  void CalculateCutOffValue( MeasureType & value ) const;
209 
211  typename DerivativeType::element_type & derivativeElement,
212  const MeasureType &value ) const;
213 
218 
220 
228  double m_SizeStd;
229 
233 
235 
237  unsigned int m_ProposalLength;
242  double m_BaseStd;
245 
248 
249 };
250 
251 } // end namespace itk
252 
253 #ifndef ITK_MANUAL_INSTANTIATION
254 #include "itkStatisticalShapePointPenalty.hxx"
255 #endif
256 
257 #endif
Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Superclass::TransformJacobianType TransformJacobianType
void CalculateCutOffDerivative(typename DerivativeType::element_type &derivativeElement, const MeasureType &value) const
Computes the Mahalanobis distance between the transformed shape and a mean shape. A model mean and co...
void UpdateCentroidAndAlignProposalDerivative(const unsigned int shapeLength) const
void CalculateDerivative(DerivativeType &derivative, const MeasureType &value, const VnlVectorType &differenceVector, const VnlVectorType &centerrotated, const VnlVectorType &eigrot, const unsigned int shapeLength) const
FixedPointSetType::PointsContainer::ConstIterator PointIterator
std::vector< VnlVectorType * > ProposalDerivativeType
Superclass::FixedPointSetType FixedPointSetType
void FillProposalDerivative(const OutputPointType &fixedPoint, const unsigned int vertexindex) const
void CalculateCutOffValue(MeasureType &value) const
void FillProposalVector(const OutputPointType &fixedPoint, const unsigned int vertexindex) const
void UpdateL2AndNormalizeProposalDerivative(const unsigned int shapeLength) const
MeasureType GetValue(const TransformParametersType &parameters) const
void CalculateValue(MeasureType &value, VnlVectorType &differenceVector, VnlVectorType &centerrotated, VnlVectorType &eigrot) const
int max(int a, int b)
TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
void UpdateL2(const unsigned int shapeLength) const
Superclass::MovingPointSetType MovingPointSetType
SingleValuedPointSetToPointSetMetric< TFixedPointSet, TMovingPointSet > Superclass
FixedPointSetType::PointDataContainer::ConstIterator PointDataIterator
void UpdateCentroidAndAlignProposalVector(const unsigned int shapeLength) const
vnl_svd_economy< CoordRepType > PCACovarianceType
void PrintSelf(std::ostream &os, Indent indent) const
void GetDerivative(const TransformParametersType &parameters, DerivativeType &Derivative) const
Superclass::MovingPointSetConstPointer MovingPointSetConstPointer
void NormalizeProposalVector(const unsigned int shapeLength) const
Superclass::DerivativeValueType DerivativeValueType
Superclass::TransformParametersType TransformParametersType
Superclass::PointDataIterator PointDataIterator
Superclass::FixedPointSetConstPointer FixedPointSetConstPointer
AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedPointSetDimension), itkGetStaticConstMacro(MovingPointSetDimension) > TransformType
void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const


Generated on 11-03-2014 for elastix by doxygen 1.8.6 elastix logo