ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkBSplineDeformableTransform.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 itkBSplineDeformableTransform_h
19 #define itkBSplineDeformableTransform_h
20 
21 #include "itkConfigure.h" // Needed to determine value of ITKV3_COMPATIBILITY
23 
24 namespace itk
25 {
113 template<typename TParametersValueType=double,
114  unsigned int NDimensions = 3,
115  unsigned int VSplineOrder = 3>
116 class ITK_TEMPLATE_EXPORT BSplineDeformableTransform :
117  public BSplineBaseTransform<TParametersValueType,NDimensions,VSplineOrder>
118 {
119 public:
125 
127  // Explicit New() method, used here because we need to split the itkNewMacro()
128  // in order to overload the CreateAnother() method so that we can copy the m_BulkTransform
129  // explicitly.
130  // TODO: shouldn't it be done with the Clone() method?
131  itkSimpleNewMacro(Self);
132  virtual ::itk::LightObject::Pointer CreateAnother(void) const ITK_OVERRIDE
133  {
135  Pointer copyPtr = Self::New().GetPointer();
136  //THE FOLLOWING LINE IS DIFFERENT FROM THE DEFAULT MACRO!
137  copyPtr->m_BulkTransform = this->GetBulkTransform();
138  smartPtr = static_cast<Pointer>( copyPtr );
139  return smartPtr;
140  }
142 
144  itkCloneMacro(Self);
145 
148 
150  itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
151 
153  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
154 
156  typedef TParametersValueType ScalarType;
157 
159  typedef typename Superclass::ParametersType ParametersType;
160  typedef typename Superclass::ParametersValueType ParametersValueType;
161  typedef typename Superclass::FixedParametersType FixedParametersType;
162  typedef typename Superclass::FixedParametersValueType FixedParametersValueType;
163 
165  typedef typename Superclass::JacobianType JacobianType;
166 
168  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
169 
171  typedef typename Superclass::InputVectorType InputVectorType;
172  typedef typename Superclass::OutputVectorType OutputVectorType;
173 
175  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
176  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
177 
179  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
180  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
181 
186 
187 
204  virtual void SetFixedParameters( const FixedParametersType & parameters ) ITK_OVERRIDE;
206 
208  typedef typename Superclass::ImageType ImageType;
209  typedef typename Superclass::ImagePointer ImagePointer;
210  typedef typename Superclass::CoefficientImageArray CoefficientImageArray;
211 
223  virtual void SetCoefficientImages( const CoefficientImageArray & images ) ITK_OVERRIDE;
224 
225 #ifdef ITKV3_COMPATIBILITY
226  virtual void SetCoefficientImage( const CoefficientImageArray & images )
227  {
228  this->SetCoefficientImages( images );
229  }
230  /* Only for backwards compatibility with ITKv3. */
231  CoefficientImageArray GetCoefficientImage()
232  {
233  return this->GetCoefficientImages();
234  }
235 #endif
236 
238  typedef typename Superclass::RegionType RegionType;
239 
241  typedef typename Superclass::SizeType SizeType;
242  typedef typename Superclass::SpacingType SpacingType;
245 
247  typedef typename Superclass::WeightsFunctionType WeightsFunctionType;
248 
249  typedef typename Superclass::WeightsType WeightsType;
250  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
251 
253  typedef typename Superclass::ParameterIndexArrayType ParameterIndexArrayType;
254 
263  using Superclass::TransformPoint;
264  virtual void TransformPoint( const InputPointType & inputPoint, OutputPointType & outputPoint,
265  WeightsType & weights, ParameterIndexArrayType & indices, bool & inside ) const ITK_OVERRIDE;
267 
268  virtual void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const ITK_OVERRIDE;
269 
271  virtual NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE;
272 
274  NumberOfParametersType GetNumberOfParametersPerDimension() const ITK_OVERRIDE;
275 
277  typedef typename Superclass::PixelType PixelType;
278 
280 
282  virtual void SetGridOrigin( const OriginType & );
283 
285  itkGetConstMacro( GridOrigin, OriginType );
286 
288  virtual void SetGridSpacing( const SpacingType & );
289 
291  itkGetConstMacro( GridSpacing, SpacingType );
292 
294  virtual void SetGridDirection( const DirectionType & );
295 
297  itkGetConstMacro( GridDirection, DirectionType );
298 
300  virtual void SetGridRegion( const RegionType & );
301 
303  itkGetConstMacro( GridRegion, RegionType );
304 
305  typedef Transform<TParametersValueType,
306  itkGetStaticConstMacro(SpaceDimension),
307  itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
308  typedef typename BulkTransformType::ConstPointer BulkTransformPointer;
312  itkSetConstObjectMacro(BulkTransform, BulkTransformType);
313  itkGetConstObjectMacro(BulkTransform, BulkTransformType);
315 
317  itkGetConstReferenceMacro(ValidRegion, RegionType);
318 
319 protected:
321  void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
322 
324  virtual ~BSplineDeformableTransform() ITK_OVERRIDE;
325 
326 private:
327 
329  virtual void SetFixedParametersGridSizeFromTransformDomainInformation() const ITK_OVERRIDE;
330 
332  virtual void SetFixedParametersGridOriginFromTransformDomainInformation() const ITK_OVERRIDE;
333 
335  virtual void SetFixedParametersGridSpacingFromTransformDomainInformation() const ITK_OVERRIDE;
336 
338  virtual void SetFixedParametersGridDirectionFromTransformDomainInformation() const ITK_OVERRIDE;
339 
341  virtual void SetCoefficientImageInformationFromFixedParameters() ITK_OVERRIDE;
342 
343  ITK_DISALLOW_COPY_AND_ASSIGN(BSplineDeformableTransform);
344 
346  virtual bool InsideValidRegion( ContinuousIndexType & ) const ITK_OVERRIDE;
347 
356  const RegionType & m_GridRegion;
357  const OriginType & m_GridOrigin;
358  const SpacingType & m_GridSpacing;
359  const DirectionType & m_GridDirection;
360 
362  BulkTransformPointer m_BulkTransform;
363 
364  RegionType m_ValidRegion;
365 
367  unsigned long m_Offset;
368  bool m_SplineOrderOdd;
369  IndexType m_ValidRegionLast;
370  IndexType m_ValidRegionFirst;
371 
372  void UpdateValidGridRegion();
373 
374 }; // class BSplineDeformableTransform
375 } // namespace itk
376 
377 #ifndef ITK_MANUAL_INSTANTIATION
378 #include "itkBSplineDeformableTransform.hxx"
379 #endif
380 
381 #endif /* itkBSplineDeformableTransform_h */
Point< TParametersValueType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType
Superclass::OutputVnlVectorType OutputVnlVectorType
Light weight base class for most itk classes.
An image region represents a structured region of data.
Superclass::FixedParametersValueType FixedParametersValueType
Superclass::NumberOfParametersType NumberOfParametersType
ObjectType * GetPointer() const
Superclass::ContinuousIndexType ContinuousIndexType
Superclass::NumberOfParametersType NumberOfParametersType
Superclass::ParametersValueType ParametersValueType
virtual ::itk::LightObject::Pointer CreateAnother(void) const override
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
Superclass::ParameterIndexArrayType ParameterIndexArrayType
Superclass::WeightsFunctionType WeightsFunctionType
Superclass::FixedParametersType FixedParametersType
Superclass::InputCovariantVectorType InputCovariantVectorType
BSplineBaseTransform< TParametersValueType, NDimensions, VSplineOrder > Superclass
A base class with common elements of BSplineTransform and BSplineDeformableTransform.
Superclass::FixedParametersType FixedParametersType
Superclass::CoefficientImageArray CoefficientImageArray
A templated class holding a point in n-Dimensional image space.
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::OutputVectorType OutputVectorType
Point< TParametersValueType, itkGetStaticConstMacro(SpaceDimension)> InputPointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Superclass::InputVnlVectorType InputVnlVectorType
Deformable transform using a BSpline representation.
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
Superclass::JacobianType JacobianType