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  * 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 __itkMultiBSplineDeformableTransformWithNormal_h
19 #define __itkMultiBSplineDeformableTransformWithNormal_h
20 
22 #include "itkNearestNeighborInterpolateImageFunction.h"
23 
24 namespace itk
25 {
38 template<
39 class TScalarType = double, // Data type for scalars
40 unsigned int NDimensions = 3, // Number of dimensions
41 unsigned int VSplineOrder = 3 >
42 // Spline order
43 class MultiBSplineDeformableTransformWithNormal :
44  public AdvancedTransform< TScalarType, NDimensions, NDimensions >
45 {
46 public:
47 
50  typedef AdvancedTransform<
51  TScalarType, NDimensions, NDimensions > Superclass;
53  typedef SmartPointer< const Self > ConstPointer;
54 
56  itkNewMacro( Self );
57 
60 
62  itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
63 
65  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
66 
82 
83  typedef typename Superclass
86  typedef typename Superclass
89  typedef typename Superclass
92 
95  itkGetStaticConstMacro( SpaceDimension ),
96  itkGetStaticConstMacro( SplineOrder ) > WeightsFunctionType;
98 
117  void SetParameters( const ParametersType & parameters );
118 
134  void SetFixedParameters( const ParametersType & parameters );
135 
152  void SetParametersByValue( const ParametersType & parameters );
153 
162  void SetIdentity( void );
163 
165  virtual const ParametersType & GetParameters( void ) const;
166 
168  virtual const ParametersType & GetFixedParameters( void ) const;
169 
171  typedef typename ParametersType::ValueType PixelType;
172  typedef Image< PixelType,
173  itkGetStaticConstMacro( SpaceDimension ) > ImageType;
174  typedef typename ImageType::Pointer ImagePointer;
175 
177  //virtual ImagePointer * GetCoefficientImage( void )
178  // { return this->m_CoefficientImage; }
179  //virtual const ImagePointer * GetCoefficientImage( void ) const
180  // { return this->m_CoefficientImage; }
181 
193  // virtual void SetCoefficientImage( ImagePointer images[] );
194 
196  typedef ImageRegion< itkGetStaticConstMacro( SpaceDimension ) > RegionType;
197 
198  typedef typename RegionType::IndexType IndexType;
199  typedef typename RegionType::SizeType SizeType;
200  typedef typename ImageType::SpacingType SpacingType;
201  typedef typename ImageType::DirectionType DirectionType;
202  typedef typename ImageType::PointType OriginType;
203  typedef IndexType GridOffsetType;
204 
206  virtual void SetGridRegion( const RegionType & region );
207 
208  virtual RegionType GetGridRegion( void ) const;
209 
211  virtual void SetGridSpacing( const SpacingType & spacing );
212 
213  virtual SpacingType GetGridSpacing( void ) const;
214 
216  virtual void SetGridDirection( const DirectionType & spacing );
217 
218  virtual DirectionType GetGridDirection( void ) const;
219 
221  virtual void SetGridOrigin( const OriginType & origin );
222 
223  virtual OriginType GetGridOrigin( void ) const;
224 
226  typedef Image< unsigned char,
227  itkGetStaticConstMacro( SpaceDimension ) > ImageLabelType;
228  typedef typename ImageLabelType::Pointer ImageLabelPointer;
229 
230  typedef itk::NearestNeighborInterpolateImageFunction<
232  typedef typename ImageLabelInterpolator::Pointer ImageLabelInterpolatorPointer;
233 
235  typedef Vector< TScalarType, itkGetStaticConstMacro( SpaceDimension ) > VectorType;
236  typedef Vector< VectorType, itkGetStaticConstMacro( SpaceDimension ) > BaseType;
238  typedef typename ImageVectorType::Pointer ImageVectorPointer;
240  typedef typename ImageBaseType::Pointer ImageBasePointer;
241 
243  void SetLabels( ImageLabelType * labels );
244 
245  itkGetMacro( Labels, ImageLabelType * );
246 
247  itkGetConstMacro( NbLabels, unsigned char );
248 
250  void UpdateLocalBases( void );
251 
252  itkGetMacro( LocalBases, ImageBaseType * );
253 
255  typedef Array< unsigned long > ParameterIndexArrayType;
256 
260  virtual OutputVectorType TransformVector( const InputVectorType & ) const
261  {
262  itkExceptionMacro( << "Method not applicable for deformable transform." );
263  return OutputVectorType();
264  }
265 
266 
270  virtual OutputVnlVectorType TransformVector( const InputVnlVectorType & ) const
271  {
272  itkExceptionMacro( << "Method not applicable for deformable transform. " );
273  return OutputVnlVectorType();
274  }
275 
276 
281  const InputCovariantVectorType & ) const
282  {
283  itkExceptionMacro( << "Method not applicable for deformable transform. " );
284  return OutputCovariantVectorType();
285  }
286 
287 
289  virtual NumberOfParametersType GetNumberOfParameters( void ) const;
290 
292  virtual NumberOfParametersType GetNumberOfParametersPerDimension( void ) const;
293 
295  virtual const RegionType & GetValidRegion( void )
296  {
297  return m_Trans[ 0 ]->GetValidRegion();
298  }
299 
300 
306  virtual bool IsLinear( void ) const { return false; }
307 
309  virtual unsigned long GetNumberOfWeights( void ) const
310  {
311  return m_Trans[ 0 ]->m_WeightsFunction->GetNumberOfWeights();
312  }
313 
314 
315  virtual unsigned int GetNumberOfAffectedWeights( void ) const
316  {
317  return m_Trans[ 0 ]->m_WeightsFunction->GetNumberOfWeights();
318  }
319 
320 
321  virtual NumberOfParametersType GetNumberOfNonZeroJacobianIndices( void ) const
322  {
323  return m_Trans[ 0 ]->m_WeightsFunction->GetNumberOfWeights() * SpaceDimension;
324  }
325 
326 
328  virtual bool GetHasNonZeroSpatialJacobian( void ) const
329  {
330  return true;
331  }
332 
333 
334  virtual bool HasNonZeroJacobianOfSpatialJacobian( void ) const
335  {
336  return true;
337  }
338 
339 
340  virtual bool GetHasNonZeroSpatialHessian( void ) const
341  {
342  return true;
343  }
344 
345 
346  virtual bool HasNonZeroJacobianOfSpatialHessian( void ) const
347  {
348  return true;
349  }
350 
351 
353  typedef ContinuousIndex< ScalarType, SpaceDimension > ContinuousIndexType;
354 
356  OutputPointType TransformPoint( const InputPointType & point ) const;
357 
359  //virtual const JacobianType & GetJacobian( const InputPointType & point ) const;
360 
362  virtual void GetJacobian(
363  const InputPointType & ipp,
364  JacobianType & j,
365  NonZeroJacobianIndicesType & ) const;
366 
368  virtual void GetSpatialJacobian(
369  const InputPointType & ipp,
370  SpatialJacobianType & sj ) const;
371 
372  virtual void GetJacobianOfSpatialJacobian(
373  const InputPointType & ipp,
374  JacobianOfSpatialJacobianType & jsj,
375  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
376 
377  virtual void GetJacobianOfSpatialJacobian(
378  const InputPointType &,
379  SpatialJacobianType &,
380  JacobianOfSpatialJacobianType &,
381  NonZeroJacobianIndicesType & ) const;
382 
384  virtual void GetSpatialHessian(
385  const InputPointType & ipp,
386  SpatialHessianType & sh ) const;
387 
389  const InputPointType & ipp,
390  JacobianOfSpatialHessianType & jsh,
391  NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const
392  {
393  itkExceptionMacro( << "ERROR: GetJacobianOfSpatialHessian() not yet implemented "
394  << "in the MultiBSplineDeformableTransformWithNormal class." );
395  }
396 
397 
398  virtual void GetJacobianOfSpatialHessian(
399  const InputPointType &,
400  SpatialHessianType &,
401  JacobianOfSpatialHessianType &,
402  NonZeroJacobianIndicesType & ) const;
403 
404 protected:
405 
407  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
408 
411 
413  // void WrapAsImages( void );
414 
416  /*
417  void TransformPointToContinuousGridIndex(
418  const InputPointType & point, ContinuousIndexType & index ) const;
419 
420  virtual void ComputeNonZeroJacobianIndices(
421  NonZeroJacobianIndicesType & nonZeroJacobianIndices,
422  const RegionType & supportRegion ) const;
423  */
424 
426  //virtual bool InsideValidRegion( const ContinuousIndexType& index ) const;
427 
429  // BulkTransformPointer m_BulkTransform;
430 
433  // ImagePointer m_CoefficientImage[ NDimensions ];
434 
436  // RegionType m_GridRegion;
437  // SpacingType m_GridSpacing;
438  // DirectionType m_GridDirection;
439  // OriginType m_GridOrigin;
440  // GridOffsetType m_GridOffsetTable;
441 
442  // DirectionType m_PointToIndexMatrix;
443  // SpatialJacobianType m_PointToIndexMatrix2;
444  // DirectionType m_PointToIndexMatrixTransposed;
445  // SpatialJacobianType m_PointToIndexMatrixTransposed2;
446  // DirectionType m_IndexToPoint;
447 
448  // RegionType m_ValidRegion;
449 
451  // unsigned long m_Offset;
452  // SizeType m_SupportSize;
453  // ContinuousIndexType m_ValidRegionBegin;
454  // ContinuousIndexType m_ValidRegionEnd;
455 
457  // bool m_SplineOrderOdd;
458 
460  const ParametersType * m_InputParametersPointer;
461 
463  /*
464  typedef typename JacobianType::ValueType JacobianPixelType;
465  typedef Image< JacobianPixelType,
466  itkGetStaticConstMacro( SpaceDimension ) > JacobianImageType;
467 
468  typename JacobianImageType::Pointer m_JacobianImage[ NDimensions ];
469  */
470 
474  // mutable IndexType m_LastJacobianIndex;
475 
477  // ImagePointer m_WrappedImage[ NDimensions ];
478 
481 
482  typedef AdvancedBSplineDeformableTransform< TScalarType,
483  itkGetStaticConstMacro( SpaceDimension ),
484  itkGetStaticConstMacro( SplineOrder ) > TransformType;
485 
486  unsigned char m_NbLabels;
487  ImageLabelPointer m_Labels;
488  ImageLabelInterpolatorPointer m_LabelsInterpolator;
489  ImageVectorPointer m_LabelsNormals;
490  std::vector< typename TransformType::Pointer > m_Trans;
491  std::vector< ParametersType > m_Para;
492  mutable int m_LastJacobian;
493  ImageBasePointer m_LocalBases;
494 
495 private:
496 
497  MultiBSplineDeformableTransformWithNormal( const Self & ); // purposely not implemented
498  void operator=( const Self & ); // purposely not implemented
499 
500  void DispatchParameters( const ParametersType & parameters );
501 
502  void PointToLabel( const InputPointType & p, int & l ) const;
503 
504 };
505 
506 } // end namespace itk
507 
508 #ifndef ITK_MANUAL_INSTANTIATION
509 #include "itkMultiBSplineDeformableTransformWithNormal.hxx"
510 #endif
511 
512 #endif // end __itkMultiBSplineDeformableTransformWithNormal_h
virtual const ParametersType & GetParameters(void) const
Matrix< ScalarType, OutputSpaceDimension, InputSpaceDimension > SpatialJacobianType
virtual void PrintSelf(std::ostream &os, Indent indent) const
Deformable transform using a B-spline representation.
virtual NumberOfParametersType GetNumberOfNonZeroJacobianIndices(void) const
virtual void SetGridRegion(const RegionType &region)
void SetParameters(const ParametersType &parameters)
virtual SpacingType GetGridSpacing(void) const
OutputPointType TransformPoint(const InputPointType &point) const
virtual void SetGridSpacing(const SpacingType &spacing)
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
virtual DirectionType GetGridDirection(void) const
virtual NumberOfParametersType GetNumberOfParameters(void) const
void PointToLabel(const InputPointType &p, int &l) const
void SetParametersByValue(const ParametersType &parameters)
Image< VectorType, itkGetStaticConstMacro(SpaceDimension) > ImageVectorType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Image< BaseType, itkGetStaticConstMacro(SpaceDimension) > ImageBaseType
virtual void GetJacobianOfSpatialJacobian(const InputPointType &ipp, JacobianOfSpatialJacobianType &jsj, NonZeroJacobianIndicesType &nonZeroJacobianIndices) const
virtual void SetGridDirection(const DirectionType &spacing)
Returns the weights over the support region used for B-spline interpolation/reconstruction.
virtual OriginType GetGridOrigin(void) const
Image< unsigned char, itkGetStaticConstMacro(SpaceDimension) > ImageLabelType
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...
void SetLabels(ImageLabelType *labels)
virtual void GetSpatialJacobian(const InputPointType &ipp, SpatialJacobianType &sj) const
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
ImageRegion< itkGetStaticConstMacro(SpaceDimension) > RegionType
void SetFixedParameters(const ParametersType &parameters)
itk::NearestNeighborInterpolateImageFunction< ImageLabelType, TScalarType > ImageLabelInterpolator
virtual RegionType GetGridRegion(void) const
This transform is a composition of B-spline transformations, allowing sliding motion between differen...
virtual void SetGridOrigin(const OriginType &origin)
itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions)
Vector< TScalarType, itkGetStaticConstMacro(SpaceDimension) > VectorType
void DispatchParameters(const ParametersType &parameters)
AdvancedTransform< TScalarType, NDimensions, NDimensions > Superclass
virtual void GetJacobian(const InputPointType &ipp, JacobianType &j, NonZeroJacobianIndicesType &) const
virtual void GetSpatialHessian(const InputPointType &ipp, SpatialHessianType &sh) const
virtual NumberOfParametersType GetNumberOfParametersPerDimension(void) const
FixedArray< Matrix< ScalarType, InputSpaceDimension, InputSpaceDimension >, OutputSpaceDimension > SpatialHessianType
AdvancedBSplineDeformableTransform< TScalarType, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder) > TransformType
Image< PixelType, itkGetStaticConstMacro(SpaceDimension) > ImageType
Vector< VectorType, itkGetStaticConstMacro(SpaceDimension) > BaseType
virtual const ParametersType & GetFixedParameters(void) const
BSplineInterpolationWeightFunction2< ScalarType, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder) > WeightsFunctionType


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo