go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkMultiBSplineDeformableTransformWithNormal.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 __itkMultiBSplineDeformableTransformWithNormal_h
15 #define __itkMultiBSplineDeformableTransformWithNormal_h
16 
18 #include "itkNearestNeighborInterpolateImageFunction.h"
19 
20 
21 namespace itk
22 {
35 template <
36  class TScalarType = double, // Data type for scalars
37  unsigned int NDimensions = 3, // Number of dimensions
38  unsigned int VSplineOrder = 3 > // Spline order
40  : public AdvancedTransform< TScalarType, NDimensions, NDimensions >
41 {
42 public:
45  typedef AdvancedTransform<
46  TScalarType, NDimensions, NDimensions > Superclass;
47  typedef SmartPointer<Self> Pointer;
48  typedef SmartPointer<const Self> ConstPointer;
49 
51  itkNewMacro( Self );
52 
55 
57  itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
58 
60  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
61 
77 
78  typedef typename Superclass
81  typedef typename Superclass
84  typedef typename Superclass
87 
90  itkGetStaticConstMacro( SpaceDimension ),
91  itkGetStaticConstMacro( SplineOrder) > WeightsFunctionType;
93 
112  void SetParameters( const ParametersType & parameters );
113 
129  void SetFixedParameters( const ParametersType & parameters );
130 
147  void SetParametersByValue( const ParametersType & parameters );
148 
157  void SetIdentity( void );
158 
160  virtual const ParametersType& GetParameters( void ) const;
161 
163  virtual const ParametersType& GetFixedParameters( void ) const;
164 
166  typedef typename ParametersType::ValueType PixelType;
167  typedef Image< PixelType,
168  itkGetStaticConstMacro( SpaceDimension )> ImageType;
169  typedef typename ImageType::Pointer ImagePointer;
170 
172  //virtual ImagePointer * GetCoefficientImage( void )
173  // { return this->m_CoefficientImage; }
174  //virtual const ImagePointer * GetCoefficientImage( void ) const
175  // { return this->m_CoefficientImage; }
176 
188  // virtual void SetCoefficientImage( ImagePointer images[] );
189 
191  typedef ImageRegion< itkGetStaticConstMacro( SpaceDimension ) > RegionType;
192 
193  typedef typename RegionType::IndexType IndexType;
194  typedef typename RegionType::SizeType SizeType;
195  typedef typename ImageType::SpacingType SpacingType;
196  typedef typename ImageType::DirectionType DirectionType;
197  typedef typename ImageType::PointType OriginType;
199 
201  virtual void SetGridRegion( const RegionType & region );
202  virtual RegionType GetGridRegion( void ) const;
203 
205  virtual void SetGridSpacing( const SpacingType & spacing );
206  virtual SpacingType GetGridSpacing( void ) const;
207 
209  virtual void SetGridDirection( const DirectionType & spacing );
210  virtual DirectionType GetGridDirection( void ) const;
211 
213  virtual void SetGridOrigin( const OriginType & origin );
214  virtual OriginType GetGridOrigin( void ) const;
215 
217  typedef Image< unsigned char,
218  itkGetStaticConstMacro( SpaceDimension ) > ImageLabelType;
219  typedef typename ImageLabelType::Pointer ImageLabelPointer;
220 
221  typedef itk::NearestNeighborInterpolateImageFunction<
223  typedef typename ImageLabelInterpolator::Pointer ImageLabelInterpolatorPointer;
224 
226  typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> VectorType;
227  typedef Vector<VectorType, itkGetStaticConstMacro(SpaceDimension)> BaseType;
228  typedef Image<VectorType, itkGetStaticConstMacro( SpaceDimension ) > ImageVectorType;
229  typedef typename ImageVectorType::Pointer ImageVectorPointer;
230  typedef Image<BaseType, itkGetStaticConstMacro( SpaceDimension ) > ImageBaseType;
231  typedef typename ImageBaseType::Pointer ImageBasePointer;
232 
234  void SetLabels( ImageLabelType* labels );
235  itkGetMacro( Labels, ImageLabelType * );
236 
237  itkGetConstMacro( NbLabels, unsigned char );
238 
240  void UpdateLocalBases( void );
241  itkGetMacro( LocalBases, ImageBaseType * );
242 
244  typedef Array<unsigned long> ParameterIndexArrayType;
245 
250  {
251  itkExceptionMacro( << "Method not applicable for deformable transform." );
252  return OutputVectorType();
253  }
254 
259  {
260  itkExceptionMacro( << "Method not applicable for deformable transform. ");
261  return OutputVnlVectorType();
262  }
263 
268  const InputCovariantVectorType & ) const
269  {
270  itkExceptionMacro( << "Method not applicable for deformable transform. ");
271  return OutputCovariantVectorType();
272  }
273 
275  virtual NumberOfParametersType GetNumberOfParameters( void ) const;
276 
278  virtual NumberOfParametersType GetNumberOfParametersPerDimension( void ) const;
279 
281  virtual const RegionType& GetValidRegion( void )
282  {
283  return m_Trans[0]->GetValidRegion();
284  }
285 
291  virtual bool IsLinear( void ) const { return false; }
292 
294  virtual unsigned long GetNumberOfWeights( void ) const
295  {
296  return m_Trans[0]->m_WeightsFunction->GetNumberOfWeights();
297  }
298 
299  virtual unsigned int GetNumberOfAffectedWeights( void ) const
300  {
301  return m_Trans[0]->m_WeightsFunction->GetNumberOfWeights();
302  }
303 
304  virtual unsigned long GetNumberOfNonZeroJacobianIndices( void ) const
305  {
306  return m_Trans[0]->m_WeightsFunction->GetNumberOfWeights() * SpaceDimension;
307  }
308 
310  virtual bool GetHasNonZeroSpatialJacobian( void ) const
311  {
312  return true;
313  }
314  virtual bool HasNonZeroJacobianOfSpatialJacobian( void ) const
315  {
316  return true;
317  }
318  virtual bool GetHasNonZeroSpatialHessian( void ) const
319  {
320  return true;
321  }
322  virtual bool HasNonZeroJacobianOfSpatialHessian( void ) const
323  {
324  return true;
325  }
326 
328  typedef ContinuousIndex<ScalarType, SpaceDimension> ContinuousIndexType;
329 
331  OutputPointType TransformPoint( const InputPointType & point ) const;
332 
334  //virtual const JacobianType & GetJacobian( const InputPointType & point ) const;
335 
337  virtual void GetJacobian(
338  const InputPointType & ipp,
339  JacobianType & j,
340  NonZeroJacobianIndicesType & ) const;
341 
343  virtual void GetSpatialJacobian(
344  const InputPointType & ipp,
345  SpatialJacobianType & sj ) const;
346 
347  virtual void GetJacobianOfSpatialJacobian(
348  const InputPointType & ipp,
350  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
351 
352  virtual void GetJacobianOfSpatialJacobian(
353  const InputPointType &,
356  NonZeroJacobianIndicesType & ) const;
357 
359  virtual void GetSpatialHessian(
360  const InputPointType & ipp,
361  SpatialHessianType & sh ) const;
362 
364  const InputPointType & ipp,
366  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const
367  {
368  itkExceptionMacro( << "ERROR: GetJacobianOfSpatialHessian() not yet implemented "
369  << "in the MultiBSplineDeformableTransformWithNormal class." );
370  }
371 
372  virtual void GetJacobianOfSpatialHessian(
373  const InputPointType &,
374  SpatialHessianType &,
375  JacobianOfSpatialHessianType &,
376  NonZeroJacobianIndicesType & ) const;
377 
378 protected:
380  virtual void PrintSelf( std::ostream &os, Indent indent ) const;
381 
384 
386  // void WrapAsImages( void );
387 
389  /*
390  void TransformPointToContinuousGridIndex(
391  const InputPointType & point, ContinuousIndexType & index ) const;
392 
393  virtual void ComputeNonZeroJacobianIndices(
394  NonZeroJacobianIndicesType & nonZeroJacobianIndices,
395  const RegionType & supportRegion ) const;
396  */
397 
399  //virtual bool InsideValidRegion( const ContinuousIndexType& index ) const;
400 
402  // BulkTransformPointer m_BulkTransform;
403 
406  // ImagePointer m_CoefficientImage[ NDimensions ];
407 
409  // RegionType m_GridRegion;
410  // SpacingType m_GridSpacing;
411  // DirectionType m_GridDirection;
412  // OriginType m_GridOrigin;
413  // GridOffsetType m_GridOffsetTable;
414 
415  // DirectionType m_PointToIndexMatrix;
416  // SpatialJacobianType m_PointToIndexMatrix2;
417  // DirectionType m_PointToIndexMatrixTransposed;
418  // SpatialJacobianType m_PointToIndexMatrixTransposed2;
419  // DirectionType m_IndexToPoint;
420 
421  // RegionType m_ValidRegion;
422 
424  // unsigned long m_Offset;
425  // SizeType m_SupportSize;
426  // ContinuousIndexType m_ValidRegionBegin;
427  // ContinuousIndexType m_ValidRegionEnd;
428 
430  // bool m_SplineOrderOdd;
431 
434 
436  /*
437  typedef typename JacobianType::ValueType JacobianPixelType;
438  typedef Image< JacobianPixelType,
439  itkGetStaticConstMacro( SpaceDimension ) > JacobianImageType;
440 
441  typename JacobianImageType::Pointer m_JacobianImage[ NDimensions ];
442  */
443 
447  // mutable IndexType m_LastJacobianIndex;
448 
450  // ImagePointer m_WrappedImage[ NDimensions ];
451 
454 
455  typedef AdvancedBSplineDeformableTransform <TScalarType,
456  itkGetStaticConstMacro( SpaceDimension ),
457  itkGetStaticConstMacro( SplineOrder) > TransformType;
458 
459  unsigned char m_NbLabels;
463  std::vector<typename TransformType::Pointer> m_Trans;
464  std::vector<ParametersType> m_Para;
465  mutable int m_LastJacobian;
467 
468 private:
469  MultiBSplineDeformableTransformWithNormal(const Self&); // purposely not implemented
470  void operator=(const Self&); // purposely not implemented
471 
472  void DispatchParameters( const ParametersType & parameters );
473  void PointToLabel( const InputPointType & p, int & l ) const;
474 
475 }; // end class MultiBSplineDeformableTransformWithNormal
476 
477 } // end namespace itk
478 
479 #ifndef ITK_MANUAL_INSTANTIATION
480 #include "itkMultiBSplineDeformableTransformWithNormal.txx"
481 #endif
482 
483 #endif // end __itkMultiBSplineDeformableTransformWithNormal_h
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
Deformable transform using a B-spline representation.
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Image< BaseType, itkGetStaticConstMacro(SpaceDimension) > ImageBaseType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Returns the weights over the support region used for B-spline interpolation/reconstruction.
class ITK_EXPORT MultiBSplineDeformableTransformWithNormal
itk::NearestNeighborInterpolateImageFunction< ImageLabelType, TScalarType > ImageLabelInterpolator
Image< unsigned char, itkGetStaticConstMacro(SpaceDimension) > ImageLabelType
BSplineInterpolationWeightFunction2< ScalarType, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder) > WeightsFunctionType
Vector< TScalarType, itkGetStaticConstMacro(SpaceDimension)> VectorType
virtual void GetJacobianOfSpatialHessian(const InputPointType &ipp, JacobianOfSpatialHessianType &jsh, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const
Transform maps points, vectors and covariant vectors from an input space to an output space...
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
ImageRegion< itkGetStaticConstMacro(SpaceDimension) > RegionType
This transform is a composition of B-spline transformations, allowing sliding motion between differen...
AdvancedTransform< TScalarType, NDimensions, NDimensions > Superclass
Image< PixelType, itkGetStaticConstMacro(SpaceDimension)> ImageType
Vector< VectorType, itkGetStaticConstMacro(SpaceDimension)> BaseType
AdvancedBSplineDeformableTransform< TScalarType, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder) > TransformType
Image< VectorType, itkGetStaticConstMacro(SpaceDimension) > ImageVectorType
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType


Generated on 04-01-2014 for elastix by doxygen 1.8.5 elastix logo