ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkBSplineBaseTransform.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 __itkBSplineBaseTransform_h
19 #define __itkBSplineBaseTransform_h
20 
21 #include <iostream>
22 #include "itkTransform.h"
23 #include "itkImage.h"
25 
26 namespace itk
27 {
33 template <typename TScalar = double, unsigned int NDimensions = 3,
34  unsigned int VSplineOrder = 3>
36  public Transform<TScalar, NDimensions, NDimensions>
37 {
38 public:
44 
46  itkTypeMacro( BSplineBaseTransform, Transform );
47 
49  itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
50 
52  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
53 
56 
59 
62 
65 
68 
71 
76 
81 
83  typedef vnl_vector_fixed<TScalar, SpaceDimension> InputVnlVectorType;
84  typedef vnl_vector_fixed<TScalar, SpaceDimension> OutputVnlVectorType;
85 
90 
110  void SetParameters( const ParametersType & parameters );
111 
134  virtual void SetFixedParameters( const ParametersType & parameters ) = 0;
136 
153  void SetParametersByValue( const ParametersType & parameters );
154 
163  void SetIdentity();
164 
166  virtual const ParametersType & GetParameters() const;
167 
169  virtual const ParametersType & GetFixedParameters() const;
170 
172  typedef typename ParametersType::ValueType ParametersValueType;
176 
188  virtual void SetCoefficientImages( const CoefficientImageArray & images ) = 0;
189 
192  {
193  return this->m_CoefficientImages;
194  }
195 
197 
208  virtual void UpdateTransformParameters( const DerivativeType & update, TScalar factor = 1.0 );
209 
212 
214  typedef typename RegionType::SizeType SizeType;
218 
220  OutputPointType TransformPoint( const InputPointType & point ) const;
221 
224  itkGetStaticConstMacro( SpaceDimension ),
225  itkGetStaticConstMacro( SplineOrder )> WeightsFunctionType;
226 
229 
232 
241  virtual void TransformPoint( const InputPointType & inputPoint, OutputPointType & outputPoint,
242  WeightsType & weights, ParameterIndexArrayType & indices, bool & inside ) const = 0;
243 
245  unsigned long GetNumberOfWeights() const
246  {
247  return m_WeightsFunction->GetNumberOfWeights();
248  }
249 
254  {
255  itkExceptionMacro( << "Method not applicable for deformable transform." );
256  }
258 
262  {
263  itkExceptionMacro( << "Method not applicable for deformable transform. " );
264  }
265 
270  const InputCovariantVectorType & ) const
271  {
272  itkExceptionMacro( << "Method not applicable for deformable transfrom. " );
273  }
275 
278  const InputPointType &, WeightsType &, ParameterIndexArrayType & ) const;
279 
280  virtual void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const = 0;
281 
283  {
284  itkExceptionMacro( << "ComputeJacobianWithRespectToPosition not yet implemented "
285  "for " << this->GetNameOfClass() );
286  }
287 
289  virtual NumberOfParametersType GetNumberOfParameters() const = 0;
290 
293 
295  {
296  return Self::BSpline;
297  }
298 
299  unsigned int GetNumberOfAffectedWeights() const;
300 
302  typedef typename ImageType::PixelType PixelType;
303 
305 
308  {
309  return this->GetNumberOfParameters();
310  }
311 
312 protected:
314  void PrintSelf( std::ostream & os, Indent indent ) const;
315 
317  virtual ~BSplineBaseTransform();
318 
320  itkSetObjectMacro( WeightsFunction, WeightsFunctionType );
321  itkGetModifiableObjectMacro(WeightsFunction, WeightsFunctionType );
323 
325  void WrapAsImages();
326 
327 protected:
330 
333 
336 
339 
342 
345 
347  virtual bool InsideValidRegion( ContinuousIndexType & ) const = 0;
348 
349  // NOTE: There is a natural duality between the
350  // two representations of of the coefficients
351  // whereby the m_InternalParametersBuffer is
352  // needed to fit into the optimization framework
353  // and the m_CoefficientImages is needed for
354  // the Jacobian computations. This implementation
355  // is an attempt to remove as much redundancy as possible
356  // and share as much information between the two
357  // instances as possible.
358  //
364 
367 
370 
371 private:
372  BSplineBaseTransform( const Self & ); // purposely not implemented
373  void operator=( const Self & ); // purposely not implemented
374 
376 }; // class BSplineBaseTransform
377 } // namespace itk
378 
379 #ifndef ITK_MANUAL_INSTANTIATION
380 #include "itkBSplineBaseTransform.hxx"
381 #endif
382 
383 #endif /* __itkBSplineBaseTransform_h */
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:238
Superclass::NumberOfParametersType NumberOfParametersType
Definition: itkTransform.h:183
SmartPointer< const Self > ConstPointer
virtual NumberOfParametersType GetNumberOfParametersPerDimension() const =0
virtual void SetFixedParametersGridSpacingFromTransformDomainInformation() const =0
Light weight base class for most itk classes.
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &) const
void operator=(const Self &)
Image< ParametersValueType, itkGetStaticConstMacro(SpaceDimension)> ImageType
virtual void SetFixedParameters(const ParametersType &parameters)=0
void SetParametersByValue(const ParametersType &parameters)
Point< TScalar, itkGetStaticConstMacro(SpaceDimension)> OutputPointType
Superclass::TransformCategoryType TransformCategoryType
virtual void SetFixedParametersGridOriginFromTransformDomainInformation() const =0
virtual void SetFixedParametersGridDirectionFromTransformDomainInformation() const =0
unsigned long GetNumberOfWeights() const
BSplineInterpolationWeightFunction< ScalarType, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType
CoefficientImageArray m_CoefficientImages
CoefficientImageArray ArrayOfImagePointerGeneratorHelper() const
An image region represents a structured region of data.
virtual OutputVectorType TransformVector(const InputVectorType &) const
WeightsFunctionType::ContinuousIndexType ContinuousIndexType
virtual NumberOfParametersType GetNumberOfParameters() const =0
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
virtual const ParametersType & GetFixedParameters() const
TPixel PixelType
Definition: itkImage.h:89
WeightsFunctionType::Pointer m_WeightsFunction
virtual TransformCategoryType GetTransformCategory() const
Superclass::NumberOfParametersType NumberOfParametersType
ImageType::DirectionType DirectionType
Superclass::ParametersType ParametersType
static const unsigned int SplineOrder
void SetFixedParametersFromTransformDomainInformation() const
CovariantVector< TScalar, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType
WeightsFunctionType::WeightsType WeightsType
virtual const char * GetNameOfClass() const
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const =0
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
ImageType::SpacingType PhysicalDimensionsType
virtual void SetCoefficientImageInformationFromFixedParameters()=0
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
unsigned int GetNumberOfAffectedWeights() const
FixedArray< ImagePointer, NDimensions > CoefficientImageArray
Superclass::DerivativeType DerivativeType
vnl_vector_fixed< TScalar, SpaceDimension > InputVnlVectorType
A base class with common elements of BSplineTransform and BSplineDeformableTransform.
Array< unsigned long > ParameterIndexArrayType
virtual void UpdateTransformParameters(const DerivativeType &update, TScalar factor=1.0)
CovariantVector< TScalar, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
virtual NumberOfParametersType GetNumberOfLocalParameters() const
void PrintSelf(std::ostream &os, Indent indent) const
A templated class holding a point in n-Dimensional image space.
ImageRegion< itkGetStaticConstMacro(SpaceDimension)> RegionType
Superclass::ScalarType ScalarType
Vector< TScalar, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType
virtual const ParametersType & GetParameters() const
Transform< TScalar, NDimensions, NDimensions > Superclass
void ComputeJacobianFromBSplineWeightsWithRespectToPosition(const InputPointType &, WeightsType &, ParameterIndexArrayType &) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
virtual bool InsideValidRegion(ContinuousIndexType &) const =0
virtual void SetCoefficientImages(const CoefficientImageArray &images)=0
Superclass::TransformCategoryType TransformCategoryType
Definition: itkTransform.h:431
Superclass::JacobianType JacobianType
void SetParameters(const ParametersType &parameters)
OutputPointType TransformPoint(const InputPointType &point) const
Point< TScalar, itkGetStaticConstMacro(SpaceDimension)> InputPointType
ParametersType::ValueType ParametersValueType
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:51
const CoefficientImageArray GetCoefficientImages() const
Returns the weights over the support region used for B-spline interpolation/reconstruction.
A templated class holding a n-Dimensional covariant vector.
Vector< TScalar, itkGetStaticConstMacro(SpaceDimension)> InputVectorType
ImageType::SpacingType SpacingType
static const unsigned int SpaceDimension
virtual void SetFixedParametersGridSizeFromTransformDomainInformation() const =0
vnl_vector_fixed< TScalar, SpaceDimension > OutputVnlVectorType
Templated n-dimensional image class.
Definition: itkImage.h:75