ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkDisplacementFieldTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 __itkDisplacementFieldTransform_h
19 #define __itkDisplacementFieldTransform_h
20 
21 #include "itkTransform.h"
22 
23 #include "itkImage.h"
27 
28 namespace itk
29 {
30 
85 template
86 <class TScalar, unsigned int NDimensions>
87 class ITK_EXPORT DisplacementFieldTransform :
88  public Transform<TScalar, NDimensions, NDimensions>
89 {
90 public:
96 
98  itkTypeMacro( DisplacementFieldTransform, Transform );
99 
101  itkNewMacro( Self );
102 
104  typedef typename Superclass::InverseTransformBasePointer InverseTransformBasePointer;
105 
108 
110  typedef typename Superclass::ParametersType ParametersType;
111  typedef typename Superclass::ParametersValueType ParametersValueType;
112 
114  typedef typename Superclass::JacobianType JacobianType;
115 
117  typedef typename Superclass::TransformCategoryType TransformCategoryType;
118 
120  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
121 
123  typedef typename Superclass::InputPointType InputPointType;
124  typedef typename Superclass::OutputPointType OutputPointType;
125 
127  typedef typename Superclass::InputVectorType InputVectorType;
128  typedef typename Superclass::OutputVectorType OutputVectorType;
129 
130  typedef typename Superclass::InputVectorPixelType InputVectorPixelType;
131  typedef typename Superclass::OutputVectorPixelType OutputVectorPixelType;
132 
134  typedef typename Superclass::InputCovariantVectorType
136  typedef typename Superclass::OutputCovariantVectorType
138 
140  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
141  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
142 
144  typedef typename Superclass::InputDiffusionTensor3DType
146  typedef typename Superclass::OutputDiffusionTensor3DType
148 
154 
156  typedef typename Superclass::DerivativeType DerivativeType;
157 
159  itkStaticConstMacro( Dimension, unsigned int, NDimensions );
160 
165 
168 
177 
180  ScalarType,
181  OutputVectorType::Dimension,
182  Dimension>
184 
189  virtual void SetDisplacementField( DisplacementFieldType* field );
190  itkGetModifiableObjectMacro(DisplacementField, DisplacementFieldType );
192 
195  virtual void SetInverseDisplacementField( DisplacementFieldType * inverseDisplacementField );
196  itkGetModifiableObjectMacro(InverseDisplacementField, DisplacementFieldType );
198 
201  virtual void SetInterpolator( InterpolatorType* interpolator );
202  itkGetModifiableObjectMacro( Interpolator, InterpolatorType );
204 
207  virtual void SetInverseInterpolator( InterpolatorType* interpolator );
208  itkGetModifiableObjectMacro(InverseInterpolator, InterpolatorType );
210 
212  itkGetConstReferenceMacro( DisplacementFieldSetTime, ModifiedTimeType );
213 
216  virtual OutputPointType TransformPoint( const InputPointType& thisPoint )
217  const;
218 
220  using Superclass::TransformVector;
221  virtual OutputVectorType TransformVector(const InputVectorType &) const
222  {
223  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
224  "TransformVector(Vector,Point)" );
225  }
227 
228  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType &)
229  const
230  {
231  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
232  "TransformVector(Vector,Point)" );
233  }
234 
235  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
236  {
237  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
238  "TransformVector(Vector,Point)" );
239  }
240 
242  using Superclass::TransformDiffusionTensor3D;
243  OutputDiffusionTensor3DType TransformDiffusionTensor(
244  const InputDiffusionTensor3DType & ) const
245  {
246  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
247  "TransformDiffusionTensor(Tensor,Point)" );
248  }
250 
251  OutputVectorPixelType TransformDiffusionTensor(const InputVectorPixelType & )
252  const
253  {
254  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
255  "TransformDiffusionTensor(Tensor,Point)" );
256  }
257 
259  using Superclass::TransformCovariantVector;
260  virtual OutputCovariantVectorType TransformCovariantVector(
261  const InputCovariantVectorType &) const
262  {
263  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
264  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
265  }
267 
268  virtual OutputVectorPixelType TransformCovariantVector(
269  const InputVectorPixelType &) const
270  {
271  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
272  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
273  }
274 
277  virtual void SetParameters(const ParametersType & params)
278  {
279  if( &(this->m_Parameters) != &params )
280  {
281  if( params.Size() != this->m_Parameters.Size() )
282  {
283  itkExceptionMacro("Input parameters size (" << params.Size()
284  << ") does not match internal size ("
285  << this->m_Parameters.Size() << ").");
286  }
287  /* copy into existing object */
288  this->m_Parameters = params;
289  this->Modified();
290  }
291  }
293 
303  virtual void SetFixedParameters( const ParametersType & );
304 
326  virtual void ComputeJacobianWithRespectToParameters(const InputPointType &,
327  JacobianType & j) const
328  {
329  j = this->m_IdentityJacobian;
330  }
332 
339  virtual void ComputeJacobianWithRespectToParameters(const IndexType &,
340  JacobianType & j) const
341  {
342  j = this->m_IdentityJacobian;
343  }
344 
349  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
350 
355  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
356 
361  virtual void ComputeJacobianWithRespectToPosition(const IndexType & x, JacobianType & j ) const;
362 
374  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
375  JacobianType & jacobian,
376  bool useSVD = false )
377  const;
378 
390  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index, JacobianType & jacobian,
391  bool useSVD = false )
392  const;
393 
394  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 );
395 
398  bool GetInverse( Self *inverse ) const;
399 
402  virtual InverseTransformBasePointer GetInverseTransform() const;
403 
405  virtual TransformCategoryType GetTransformCategory() const
406  {
407  return Self::DisplacementField;
408  }
409 
410  virtual NumberOfParametersType GetNumberOfLocalParameters(void) const
411  {
412  return Dimension;
413  }
414 
415 protected:
416 
418  virtual ~DisplacementFieldTransform();
419  void PrintSelf( std::ostream& os, Indent indent ) const;
420 
424 
428 
432 
436 
437 private:
438  DisplacementFieldTransform( const Self & ); // purposely not implemented
439  void operator=( const Self & ); // purposely not implemented
440 
449  virtual void ComputeJacobianWithRespectToPositionInternal(const IndexType & index, JacobianType & jacobian,
450  bool doInverseJacobian) const;
451 
456  virtual void VerifyFixedParametersInformation();
457 
462  virtual void SetFixedParametersFromDisplacementField() const;
463 
464 };
465 
466 } // end namespace itk
467 
468 #ifndef ITK_MANUAL_INSTANTIATION
469 #include "itkDisplacementFieldTransform.hxx"
470 #endif
471 
472 #endif // __itkDisplacementFieldTransform_h
473