ITK  4.3.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 
164 
167 
176 
179  ScalarType,
180  OutputVectorType::Dimension,
181  Dimension>
183 
185  itkGetObjectMacro( DisplacementField, DisplacementFieldType );
186 
190  virtual void SetDisplacementField( DisplacementFieldType* field );
191 
194  itkGetObjectMacro( InverseDisplacementField, DisplacementFieldType );
195  virtual void SetInverseDisplacementField( DisplacementFieldType * inverseDisplacementField );
197 
199  itkGetObjectMacro( Interpolator, InterpolatorType );
200  /* Create out own set accessor that assigns the displacement field */
201  virtual void SetInterpolator( InterpolatorType* interpolator );
203 
205  itkGetObjectMacro( InverseInterpolator, InterpolatorType );
206  /* Create out own set accessor that assigns the displacement field */
207  virtual void SetInverseInterpolator( InterpolatorType* interpolator );
209 
211  itkGetConstReferenceMacro( DisplacementFieldSetTime, ModifiedTimeType );
212 
215  virtual OutputPointType TransformPoint( const InputPointType& thisPoint )
216  const;
217 
219  using Superclass::TransformVector;
220  virtual OutputVectorType TransformVector(const InputVectorType &) const
221  {
222  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
223  "TransformVector(Vector,Point)" );
224  }
226 
227  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType &)
228  const
229  {
230  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
231  "TransformVector(Vector,Point)" );
232  }
233 
234  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
235  {
236  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
237  "TransformVector(Vector,Point)" );
238  }
239 
241  using Superclass::TransformDiffusionTensor3D;
242  OutputDiffusionTensor3DType TransformDiffusionTensor(
243  const InputDiffusionTensor3DType & ) const
244  {
245  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
246  "TransformDiffusionTensor(Tensor,Point)" );
247  }
249 
250  OutputVectorPixelType TransformDiffusionTensor(const InputVectorPixelType & )
251  const
252  {
253  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
254  "TransformDiffusionTensor(Tensor,Point)" );
255  }
256 
258  using Superclass::TransformCovariantVector;
259  virtual OutputCovariantVectorType TransformCovariantVector(
260  const InputCovariantVectorType &) const
261  {
262  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
263  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
264  }
266 
267  virtual OutputVectorPixelType TransformCovariantVector(
268  const InputVectorPixelType &) const
269  {
270  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
271  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
272  }
273 
276  virtual void SetParameters(const ParametersType & params)
277  {
278  if( &(this->m_Parameters) != &params )
279  {
280  if( params.Size() != this->m_Parameters.Size() )
281  {
282  itkExceptionMacro("Input parameters size (" << params.Size()
283  << ") does not match internal size ("
284  << this->m_Parameters.Size() << ").");
285  }
286  /* copy into existing object */
287  this->m_Parameters = params;
288  this->Modified();
289  }
290  }
292 
302  virtual void SetFixedParameters( const ParametersType & );
303 
325  virtual void ComputeJacobianWithRespectToParameters(const InputPointType &,
326  JacobianType & j) const
327  {
328  j = this->m_IdentityJacobian;
329  }
331 
338  virtual void ComputeJacobianWithRespectToParameters(const IndexType &,
339  JacobianType & j) const
340  {
341  j = this->m_IdentityJacobian;
342  }
343 
348  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
349 
354  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
355 
360  virtual void ComputeJacobianWithRespectToPosition(const IndexType & x, JacobianType & j ) const;
361 
373  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
374  JacobianType & jacobian,
375  bool useSVD = false )
376  const;
377 
389  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index, JacobianType & jacobian,
390  bool useSVD = false )
391  const;
392 
393  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 );
394 
397  bool GetInverse( Self *inverse ) const;
398 
401  virtual InverseTransformBasePointer GetInverseTransform() const;
402 
404  virtual TransformCategoryType GetTransformCategory() const
405  {
406  return Self::DisplacementField;
407  }
408 
409  virtual NumberOfParametersType GetNumberOfLocalParameters(void) const
410  {
411  return Dimension;
412  }
413 
414 protected:
415 
417  virtual ~DisplacementFieldTransform();
418  void PrintSelf( std::ostream& os, Indent indent ) const;
419 
423 
427 
431 
435 
436 private:
437  DisplacementFieldTransform( const Self & ); // purposely not implemented
438  void operator=( const Self & ); // purposely not implemented
439 
448  virtual void ComputeJacobianWithRespectToPositionInternal(const IndexType & index, JacobianType & jacobian,
449  bool doInverseJacobian) const;
450 
455  virtual void VerifyFixedParametersInformation();
456 
461  virtual void SetFixedParametersFromDisplacementField() const;
462 
463 };
464 
465 } // end namespace itk
466 
467 #ifndef ITK_MANUAL_INSTANTIATION
468 #include "itkDisplacementFieldTransform.hxx"
469 #endif
470 
471 #endif // __itkDisplacementFieldTransform_h
472