ITK  4.2.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::NumberOfParametersType NumberOfParametersType;
118 
120  typedef typename Superclass::InputPointType InputPointType;
121  typedef typename Superclass::OutputPointType OutputPointType;
122 
124  typedef typename Superclass::InputVectorType InputVectorType;
125  typedef typename Superclass::OutputVectorType OutputVectorType;
126 
127  typedef typename Superclass::InputVectorPixelType InputVectorPixelType;
128  typedef typename Superclass::OutputVectorPixelType OutputVectorPixelType;
129 
131  typedef typename Superclass::InputCovariantVectorType
133  typedef typename Superclass::OutputCovariantVectorType
135 
137  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
138  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
139 
141  typedef typename Superclass::InputDiffusionTensor3DType
143  typedef typename Superclass::OutputDiffusionTensor3DType
145 
151 
153  typedef typename Superclass::DerivativeType DerivativeType;
154 
156  itkStaticConstMacro( Dimension, unsigned int, NDimensions );
157 
161 
164 
173 
176  ScalarType,
177  OutputVectorType::Dimension,
178  Dimension>
180 
182  itkGetObjectMacro( DisplacementField, DisplacementFieldType );
183 
187  virtual void SetDisplacementField( DisplacementFieldType* field );
188 
190  itkGetObjectMacro( InverseDisplacementField, DisplacementFieldType );
191  virtual void SetInverseDisplacementField( DisplacementFieldType * inverseDisplacementField );
193 
195  itkGetObjectMacro( Interpolator, InterpolatorType );
196  /* Create out own set accessor that assigns the displacement field */
197  virtual void SetInterpolator( InterpolatorType* interpolator );
199 
201  itkGetConstReferenceMacro( DisplacementFieldSetTime, unsigned long );
202 
205  virtual OutputPointType TransformPoint( const InputPointType& thisPoint )
206  const;
207 
209  using Superclass::TransformVector;
210  virtual OutputVectorType TransformVector(const InputVectorType &) const
211  {
212  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
213  "TransformVector(Vector,Point)" );
214  }
216 
217  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType &)
218  const
219  {
220  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
221  "TransformVector(Vector,Point)" );
222  }
223 
224  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
225  {
226  itkExceptionMacro( "TransformVector(Vector) unimplemented, use "
227  "TransformVector(Vector,Point)" );
228  }
229 
231  using Superclass::TransformDiffusionTensor3D;
232  OutputDiffusionTensor3DType TransformDiffusionTensor(
233  const InputDiffusionTensor3DType & ) const
234  {
235  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
236  "TransformDiffusionTensor(Tensor,Point)" );
237  }
239 
240  OutputVectorPixelType TransformDiffusionTensor(const InputVectorPixelType & )
241  const
242  {
243  itkExceptionMacro( "TransformDiffusionTensor(Tensor) unimplemented, use "
244  "TransformDiffusionTensor(Tensor,Point)" );
245  }
246 
248  using Superclass::TransformCovariantVector;
249  virtual OutputCovariantVectorType TransformCovariantVector(
250  const InputCovariantVectorType &) const
251  {
252  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
253  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
254  }
256 
257  virtual OutputVectorPixelType TransformCovariantVector(
258  const InputVectorPixelType &) const
259  {
260  itkExceptionMacro( "TransformCovariantVector(CovariantVector) "
261  "unimplemented, use TransformCovariantVector(CovariantVector,Point)" );
262  }
263 
266  virtual void SetParameters(const ParametersType & params)
267  {
268  if( &(this->m_Parameters) != &params )
269  {
270  if( params.Size() != this->m_Parameters.Size() )
271  {
272  itkExceptionMacro("Input parameters size (" << params.Size()
273  << ") does not match internal size ("
274  << this->m_Parameters.Size() << ").");
275  }
276  /* copy into existing object */
277  this->m_Parameters = params;
278  this->Modified();
279  }
280  }
282 
292  virtual void SetFixedParameters( const ParametersType & );
293 
315  virtual void ComputeJacobianWithRespectToParameters(const InputPointType &,
316  JacobianType & j) const
317  {
318  j = this->m_IdentityJacobian;
319  }
321 
328  virtual void ComputeJacobianWithRespectToParameters(const IndexType &,
329  JacobianType & j) const
330  {
331  j = this->m_IdentityJacobian;
332  }
333 
338  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
339 
344  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, JacobianType & j ) const;
345 
350  virtual void ComputeJacobianWithRespectToPosition(const IndexType & x, JacobianType & j ) const;
351 
363  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
364  JacobianType & jacobian,
365  bool useSVD = false )
366  const;
367 
379  virtual void GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index, JacobianType & jacobian,
380  bool useSVD = false )
381  const;
382 
383  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 );
384 
386  bool GetInverse( Self *inverse ) const;
387 
389  virtual InverseTransformBasePointer GetInverseTransform() const;
390 
392  virtual bool IsLinear() const
393  {
394  return false;
395  }
396 
397  virtual NumberOfParametersType GetNumberOfLocalParameters(void) const
398  {
399  return Dimension;
400  }
401 
402  virtual bool HasLocalSupport() const
403  {
404  return true;
405  }
406 
407 protected:
408 
410  virtual ~DisplacementFieldTransform();
411  void PrintSelf( std::ostream& os, Indent indent ) const;
412 
416 
419 
423 
427 private:
428  DisplacementFieldTransform( const Self & ); // purposely not implemented
429  void operator=( const Self & ); // purposely not implemented
431 
440  virtual void ComputeJacobianWithRespectToPositionInternal(const IndexType & index, JacobianType & jacobian,
441  bool doInverseJacobian) const;
442 
447  virtual void VerifyFixedParametersInformation();
448 
453  virtual void SetFixedParametersFromDisplacementField() const;
454 
455 };
456 
457 } // end namespace itk
458 
459 #if ITK_TEMPLATE_EXPLICIT
460 #include "Templates/itkDisplacementFieldTransform+-.h"
461 #endif
462 
463 #if ITK_TEMPLATE_TXX
464 #include "itkDisplacementFieldTransform.hxx"
465 #endif
466 
467 #endif // __itkDisplacementFieldTransform_h
468