ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkCompositeTransform.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 __itkCompositeTransform_h
19 #define __itkCompositeTransform_h
20 
21 #include "itkMultiTransform.h"
22 
23 #include <deque>
24 
25 namespace itk
26 {
27 
86 template
87 <class TScalar = double, unsigned int NDimensions = 3>
89  public MultiTransform<TScalar, NDimensions>
90 {
91 public:
97 
99  itkTypeMacro( CompositeTransform, Transform );
100 
102  itkNewMacro( Self );
103 
105  typedef typename Superclass::TransformType TransformType;
107 
110 
113 
117 
120 
123 
126 
130 
134 
138 
142 
146 
150 
154 
157 
160 
162  typedef std::deque<bool> TransformsToOptimizeFlagsType;
163 
165  itkStaticConstMacro( InputDimension, unsigned int, NDimensions );
166  itkStaticConstMacro( OutputDimension, unsigned int, NDimensions );
168 
171  virtual void SetNthTransformToOptimize( SizeValueType i, bool state )
172  {
173  this->m_TransformsToOptimizeFlags.at(i) = state;
174  this->Modified();
175  }
176 
178  {
179  this->SetNthTransformToOptimize( i, true );
180  }
181 
183  {
184  this->SetNthTransformToOptimize( i, false );
185  }
186 
187  virtual void SetAllTransformsToOptimize( bool state )
188  {
189  this->m_TransformsToOptimizeFlags.assign(
190  this->m_TransformsToOptimizeFlags.size(), state );
191  this->Modified();
192  }
193 
195  {
196  this->SetAllTransformsToOptimize( true );
197  }
198 
200  {
201  this->SetAllTransformsToOptimize( false );
202  }
203 
204  /* With AddTransform() as the only way to add a transform, we
205  * can have this method to easily allow user to optimize only
206  * the transform added most recenlty. */
208  {
209  this->SetAllTransformsToOptimize( false );
211  }
212 
213  /* Get whether the Nth transform is set to be optimzied */
214  /* NOTE: ambiguous function name here - are we getting if the Nth transform
215  is set to be optimized, or the Nth of the transforms that are set to be
216  optimized? */
217  virtual bool GetNthTransformToOptimize( SizeValueType i ) const
218  {
219  return this->m_TransformsToOptimizeFlags.at(i);
220  }
221 
224  {
225  return this->m_TransformsToOptimizeFlags;
226  }
227 
228  virtual void ClearTransformQueue()
229  {
231  this->m_TransformsToOptimizeFlags.clear();
232  }
233 
239  bool GetInverse( Self *inverse ) const;
240 
242 
257  virtual OutputPointType TransformPoint( const InputPointType & inputPoint ) const;
258 
261  virtual OutputVectorType TransformVector(const InputVectorType &) const;
262 
263  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & inputVector) const;
264 
265  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType & inputVector ) const;
266 
267  virtual OutputVectorType TransformVector(const InputVectorType & inputVector,
268  const InputPointType & inputPoint ) const;
269 
270  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & inputVector,
271  const InputPointType & inputPoint ) const;
272 
273  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType & inputVector,
274  const InputPointType & inputPoint ) const;
275 
279 
281 
283  const InputPointType & inputPoint ) const;
284 
286  const InputPointType & inputPoint ) const;
287 
291  const InputDiffusionTensor3DType & inputTensor) const;
292 
294  const InputVectorPixelType & inputTensor) const;
295 
297  const InputDiffusionTensor3DType & inputTensor,
298  const InputPointType & inputPoint ) const;
299 
301  const InputVectorPixelType & inputTensor,
302  const InputPointType & inputPoint ) const;
303 
307  const InputSymmetricSecondRankTensorType & inputTensor) const;
308 
310  const InputVectorPixelType & inputTensor) const;
311 
313  const InputSymmetricSecondRankTensorType & inputTensor,
314  const InputPointType & inputPoint ) const;
315 
317  const InputVectorPixelType & inputTensor,
318  const InputPointType & inputPoint ) const;
319 
325 
336  virtual const ParametersType & GetParameters(void) const;
337 
338  /* SetParameters only for transforms that are set to be optimized
339  * See GetParameters() for parameter ordering. */
340  virtual void SetParameters(const ParametersType & p);
341 
342  /* GetFixedParameters only for transforms that are set to be optimized
343  * See GetParameters() for parameter ordering. */
344  virtual const ParametersType & GetFixedParameters(void) const;
345 
346  /* SetFixedParameters only for transforms that are set to be optimized.
347  * See GetParameters() for parameter ordering. */
348  virtual void SetFixedParameters(const ParametersType & fixedParameters);
349 
350  /* Get total number of parameters for transforms that are set to be
351  * optimized */
352  virtual NumberOfParametersType GetNumberOfParameters(void) const;
353 
354  /* Get total number of local parameters for transforms that are set
355  * to be optimized */
357 
358  /* Get total number of fixed parameters for transforms that are set
359  * to be optimized */
361 
364  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 );
365 
369  virtual void FlattenTransformQueue();
370 
375  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & j) const ITK_OVERRIDE;
376 
386  virtual void ComputeJacobianWithRespectToParametersCachedTemporaries( const InputPointType & p, JacobianType & outJacobian, JacobianType & jacobianWithRespectToPosition ) const ITK_OVERRIDE;
388 
389 protected:
391  virtual ~CompositeTransform();
392  void PrintSelf( std::ostream& os, Indent indent ) const;
393 
395  virtual typename LightObject::Pointer InternalClone() const;
396 
398  {
400  /* Add element to list of flags, and set true by default */
401  this->m_TransformsToOptimizeFlags.push_front( true );
402  }
403 
405  {
407  /* Add element to list of flags, and set true by default */
408  this->m_TransformsToOptimizeFlags.push_back( true );
409  }
410 
411  virtual void PopFrontTransform()
412  {
414  this->m_TransformsToOptimizeFlags.pop_front();
415  }
416 
417  virtual void PopBackTransform()
418  {
420  this->m_TransformsToOptimizeFlags.pop_back();
421  }
422 
425 
428 
429 private:
430  CompositeTransform( const Self & ); // purposely not implemented
431  void operator=( const Self & ); // purposely not implemented
432 
434 
435 };
436 
437 } // end namespace itk
438 
439 #ifndef ITK_MANUAL_INSTANTIATION
440 #include "itkCompositeTransform.hxx"
441 #endif
442 
443 #endif // __itkCompositeTransform_h
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:238
Superclass::TransformCategoryType TransformCategoryType
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
virtual void SetAllTransformsToOptimize(bool state)
static const unsigned int OutputDimension
Superclass::ParametersValueType ParametersValueType
Light weight base class for most itk classes.
virtual void ComputeJacobianWithRespectToParametersCachedTemporaries(const InputPointType &p, JacobianType &outJacobian, JacobianType &jacobianWithRespectToPosition) const ITK_OVERRIDE
virtual TransformCategoryType GetTransformCategory() const
Superclass::JacobianType JacobianType
Superclass::InputPointType InputPointType
virtual bool GetNthTransformToOptimize(SizeValueType i) const
Superclass::OutputVnlVectorType OutputVnlVectorType
virtual void UpdateTransformParameters(const DerivativeType &update, ScalarType factor=1.0)
Superclass::OutputVectorType OutputVectorType
virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &tensor, const InputPointType &point) const
Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
TransformQueueType m_TransformsToOptimizeQueue
Superclass::ParametersValueType ParametersValueType
Superclass::InputVnlVectorType InputVnlVectorType
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
bool GetInverse(Self *inverse) const
virtual void SetNthTransformToOptimizeOn(SizeValueType i)
Superclass::DerivativeType DerivativeType
ModifiedTimeType m_PreviousTransformsToOptimizeUpdateTime
virtual InverseTransformBasePointer GetInverseTransform() const
virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor) const
Superclass::JacobianType JacobianType
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
Superclass::OutputPointType OutputPointType
virtual void SetAllTransformsToOptimizeOn()
virtual void SetFixedParameters(const ParametersType &fixedParameters)
Superclass::TransformType TransformType
virtual void PushBackTransform(TransformTypePointer t)
Superclass::InputVectorType InputVectorType
virtual NumberOfParametersType GetNumberOfParameters(void) const
Superclass::TransformTypePointer TransformTypePointer
Superclass::TransformCategoryType TransformCategoryType
virtual void PopFrontTransform()
MultiTransform< TScalar, NDimensions, NDimensions > Superclass
virtual void ClearTransformQueue()
SmartPointer< Self > Pointer
unsigned long SizeValueType
Definition: itkIntTypes.h:143
virtual const TransformsToOptimizeFlagsType & GetTransformsToOptimizeFlags() const
Superclass::NumberOfParametersType NumberOfParametersType
virtual void FlattenTransformQueue()
TransformQueueType & GetTransformsToOptimizeQueue() const
virtual const ParametersType & GetFixedParameters(void) const
virtual void PopBackTransform()
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
Superclass::OutputVectorPixelType OutputVectorPixelType
static const unsigned int InputDimension
virtual LightObject::Pointer InternalClone() const
Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
virtual void PushFrontTransform(TransformTypePointer t)
virtual void SetAllTransformsToOptimizeOff()
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
Superclass::ScalarType ScalarType
virtual void PushBackTransform(TransformTypePointer t)
Superclass::InverseTransformBasePointer InverseTransformBasePointer
SmartPointer< const Self > ConstPointer
This class contains a list of transforms and concatenates them by composition.
Superclass::InputVectorType InputVectorType
virtual void SetParameters(const ParametersType &p)
Superclass::ScalarType ScalarType
Superclass::OutputCovariantVectorType OutputCovariantVectorType
std::deque< TransformTypePointer > TransformQueueType
Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
virtual OutputVectorType TransformVector(const InputVectorType &) const
virtual void Modified() const
Superclass::InverseTransformBasePointer InverseTransformBasePointer
Superclass::OutputVectorPixelType OutputVectorPixelType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
Superclass::InputPointType InputPointType
Superclass::InputVnlVectorType InputVnlVectorType
Superclass::TransformQueueType TransformQueueType
This abstract class contains a list of transforms and provides basic methods.
Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
Superclass::OutputVnlVectorType OutputVnlVectorType
virtual const ParametersType & GetParameters(void) const
virtual void SetNthTransformToOptimize(SizeValueType i, bool state)
Superclass::InputVectorPixelType InputVectorPixelType
Superclass::NumberOfParametersType NumberOfParametersType
Superclass::OutputVectorType OutputVectorType
void PrintSelf(std::ostream &os, Indent indent) const
virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &inputTensor) const
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual OutputPointType TransformPoint(const InputPointType &inputPoint) const
Superclass::ParametersType ParametersType
Superclass::OutputPointType OutputPointType
Superclass::OutputCovariantVectorType OutputCovariantVectorType
virtual void SetOnlyMostRecentTransformToOptimizeOn()
Superclass::InputVectorPixelType InputVectorPixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void operator=(const Self &)
std::deque< bool > TransformsToOptimizeFlagsType
TransformsToOptimizeFlagsType m_TransformsToOptimizeFlags
Transform< TScalar, NSubDimensions, NSubDimensions > TransformType
virtual void PushFrontTransform(TransformTypePointer t)
Superclass::DerivativeType DerivativeType
virtual NumberOfParametersType GetNumberOfLocalParameters(void) const
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &j) const ITK_OVERRIDE
virtual NumberOfParametersType GetNumberOfFixedParameters(void) const
virtual SizeValueType GetNumberOfTransforms() const
virtual void SetNthTransformToOptimizeOff(SizeValueType i)
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
Superclass::ParametersType ParametersType
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &) const
Definition: itkTransform.h:272