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  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkStatisticalShapePointPenalty_h
19 #define __itkStatisticalShapePointPenalty_h
20 
22 
23 #include "itkPoint.h"
24 #include "itkPointSet.h"
25 #include "itkImage.h"
26 #include "itkArray.h"
27 #include <itkVariableSizeMatrix.h>
28 
29 #include <vnl/vnl_matrix.h>
30 #include <vnl/vnl_math.h>
31 #include <vnl/vnl_vector.h>
32 #include <vnl/algo/vnl_real_eigensystem.h>
33 #include <vnl/algo/vnl_symmetric_eigensystem.h>
34 //#include <vnl/algo/vnl_svd.h>
35 #include <vnl/algo/vnl_svd_economy.h>
36 
37 #include <vcl_iostream.h>
38 #include <string>
39 
40 namespace itk
41 {
56 template< class TFixedPointSet, class TMovingPointSet >
58  public SingleValuedPointSetToPointSetMetric< TFixedPointSet, TMovingPointSet >
59 {
60 public:
61 
65  TFixedPointSet, TMovingPointSet > Superclass;
67  typedef SmartPointer< const Self > ConstPointer;
68 
70  itkNewMacro( Self );
71 
73  itkTypeMacro( StatisticalShapePointPenalty,
75 
82 
90 
93 
96 
97  typedef typename OutputPointType::CoordRepType CoordRepType;
99  typedef vnl_matrix< CoordRepType > VnlMatrixType;
100  //typedef itk::Array<VnlVectorType *> ProposalDerivativeType;
101  typedef typename std::vector< VnlVectorType * > ProposalDerivativeType;
102  //typedef typename vnl_vector<VnlVectorType *> ProposalDerivativeType; //Cannot be linked
103  typedef vnl_svd_economy< CoordRepType > PCACovarianceType;
104 
106  void Initialize( void ) throw ( ExceptionObject );
107 
109  MeasureType GetValue( const TransformParametersType & parameters ) const;
110 
112  void GetDerivative( const TransformParametersType & parameters,
113  DerivativeType & Derivative ) const;
114 
116  void GetValueAndDerivative( const TransformParametersType & parameters,
117  MeasureType & Value, DerivativeType & Derivative ) const;
118 
120  itkSetClampMacro( ShrinkageIntensity, MeasureType, 0.0, 1.0 );
121  itkGetMacro( ShrinkageIntensity, MeasureType );
122 
123  itkSetMacro( ShrinkageIntensityNeedsUpdate, bool );
124  itkBooleanMacro( ShrinkageIntensityNeedsUpdate );
125 
127  itkSetClampMacro( BaseVariance, MeasureType,
128  -1.0, NumericTraits< MeasureType >::max() );
129  itkGetMacro( BaseVariance, MeasureType );
130 
131  itkSetMacro( BaseVarianceNeedsUpdate, bool );
132  itkBooleanMacro( BaseVarianceNeedsUpdate );
133 
134  itkSetClampMacro( CentroidXVariance, MeasureType,
135  -1.0, NumericTraits< MeasureType >::max() );
136  itkGetMacro( CentroidXVariance, MeasureType );
137 
138  itkSetClampMacro( CentroidYVariance, MeasureType,
139  -1.0, NumericTraits< MeasureType >::max() );
140  itkGetMacro( CentroidYVariance, MeasureType );
141 
142  itkSetClampMacro( CentroidZVariance, MeasureType,
143  -1.0, NumericTraits< MeasureType >::max() );
144  itkGetMacro( CentroidZVariance, MeasureType );
145 
146  itkSetClampMacro( SizeVariance, MeasureType,
147  -1.0, NumericTraits< MeasureType >::max() );
148  itkGetMacro( SizeVariance, MeasureType );
149 
150  itkSetMacro( VariancesNeedsUpdate, bool );
151  itkBooleanMacro( VariancesNeedsUpdate );
152 
153  itkSetClampMacro( CutOffValue, MeasureType,
154  0.0, NumericTraits< MeasureType >::max() );
155  itkGetMacro( CutOffValue, MeasureType );
156 
157  itkSetClampMacro( CutOffSharpness, MeasureType,
158  NumericTraits< MeasureType >::NonpositiveMin(), NumericTraits< MeasureType >::max() );
159  itkGetMacro( CutOffSharpness, MeasureType );
160 
161  itkSetMacro( ShapeModelCalculation, int );
162  itkGetConstReferenceMacro( ShapeModelCalculation, int );
163 
164  itkSetMacro( NormalizedShapeModel, bool );
165  itkGetConstReferenceMacro( NormalizedShapeModel, bool );
166  itkBooleanMacro( NormalizedShapeModel );
167 
168  itkSetConstObjectMacro( EigenVectors, vnl_matrix< double > );
169  itkSetConstObjectMacro( EigenValues, vnl_vector< double > );
170  itkSetConstObjectMacro( MeanVector, vnl_vector< double > );
171 
172  itkSetConstObjectMacro( CovarianceMatrix, vnl_matrix< double > );
173 
174 protected:
175 
177  virtual ~StatisticalShapePointPenalty();
178 
180  void PrintSelf( std::ostream & os, Indent indent ) const;
181 
182 private:
183 
184  StatisticalShapePointPenalty( const Self & ); // purposely not implemented
185  void operator=( const Self & ); // purposely not implemented
186 
187  void FillProposalVector( const OutputPointType & fixedPoint,
188  const unsigned int vertexindex ) const;
189 
190  void FillProposalDerivative( const OutputPointType & fixedPoint,
191  const unsigned int vertexindex ) const;
192 
194  const unsigned int shapeLength ) const;
195 
197  const unsigned int shapeLength ) const;
198 
199  void UpdateL2( const unsigned int shapeLength ) const;
200 
201  void NormalizeProposalVector( const unsigned int shapeLength ) const;
202 
203  void UpdateL2AndNormalizeProposalDerivative( const unsigned int shapeLength ) const;
204 
205  void CalculateValue( MeasureType & value, VnlVectorType & differenceVector,
206  VnlVectorType & centerrotated, VnlVectorType & eigrot ) const;
207 
208  void CalculateDerivative( DerivativeType & derivative, const MeasureType & value,
209  const VnlVectorType & differenceVector, const VnlVectorType & centerrotated,
210  const VnlVectorType & eigrot, const unsigned int shapeLength ) const;
211 
212  void CalculateCutOffValue( MeasureType & value ) const;
213 
215  typename DerivativeType::element_type & derivativeElement,
216  const MeasureType &value ) const;
217 
218  const VnlVectorType * m_MeanVector;
219  const VnlMatrixType * m_CovarianceMatrix;
220  const VnlMatrixType * m_EigenVectors;
221  const VnlVectorType * m_EigenValues;
222 
223  VnlMatrixType * m_InverseCovarianceMatrix;
224 
232  double m_SizeStd;
233 
237 
238  VnlVectorType * m_EigenValuesRegularized;
239 
240  mutable ProposalDerivativeType * m_ProposalDerivative;
241  unsigned int m_ProposalLength;
246  double m_BaseStd;
247  mutable VnlVectorType m_ProposalVector;
248  mutable VnlVectorType m_MeanValues;
249 
252 
253 };
254 
255 } // end namespace itk
256 
257 #ifndef ITK_MANUAL_INSTANTIATION
258 #include "itkStatisticalShapePointPenalty.hxx"
259 #endif
260 
261 #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 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo