ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkDisplacementFieldToBSplineImageFilter.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 itkDisplacementFieldToBSplineImageFilter_h
19 #define itkDisplacementFieldToBSplineImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 
24 #include "itkPointSet.h"
25 #include "itkVector.h"
26 
27 namespace itk
28 {
29 
41 template <typename TInputImage,
42  typename TInputPointSet = PointSet<typename TInputImage::PixelType, TInputImage::ImageDimension>,
43  typename TOutputImage = TInputImage>
44 class ITK_TEMPLATE_EXPORT DisplacementFieldToBSplineImageFilter
45  : public ImageToImageFilter<TInputImage, TOutputImage>
46 {
47 public:
52 
54  itkNewMacro( Self );
55 
57  itkStaticConstMacro( ImageDimension, unsigned int, TInputImage::ImageDimension );
58 
59  typedef TInputImage InputFieldType;
60  typedef TInputPointSet InputPointSetType;
61  typedef TOutputImage OutputFieldType;
62 
66 
68  typedef typename OutputFieldType::PixelType PixelType;
69  typedef typename OutputFieldType::PixelType VectorType;
70  typedef typename OutputFieldType::RegionType RegionType;
72 
73  typedef typename OutputFieldType::SpacingType SpacingType;
77 
78  typedef typename VectorType::RealValueType RealType;
80 
83  typedef typename InputPointSetType::PixelType PointDataType;
84  typedef typename InputPointSetType::PointsContainer PointsContainerType;
85  typedef typename InputPointSetType::PointDataContainer PointDataContainerType;
86 
93 
95  void SetDisplacementField( const InputFieldType * field )
96  {
97  this->SetInput( 0, field );
98  }
99 
102  {
103  return this->GetInput( 0 );
104  }
105 
111  void SetConfidenceImage( const RealImageType *image )
112  {
113  this->SetNthInput( 1, const_cast<RealImageType *>( image ) );
114  }
115  void SetInput1( const RealImageType *image ) { this->SetConfidenceImage( image ); }
117 
120  {
121  return static_cast<const RealImageType*>( this->ProcessObject::GetInput( 1 ) );
122  }
123 
125  void SetPointSet( const InputPointSetType * points )
126  {
127  this->SetNthInput( 2, const_cast<InputPointSetType *>( points ) );
128  }
129  void SetInput2( const InputPointSetType * points ) { this->SetPointSet( points ); }
131 
134  {
135  return static_cast<const InputPointSetType *>( this->ProcessObject::GetInput( 2 ) );
136  }
137 
139  void SetPointSetConfidenceWeights( WeightsContainerType *weights );
140 
143  {
144  return static_cast<const DisplacementFieldControlPointLatticeType*>( this->GetOutput( 1 ) );
145  }
146 
148  void SetBSplineDomainFromImage( RealImageType * );
149 
152  { this->SetBSplineDomainFromImage( const_cast<RealImageType *>( image ) ); }
153 
155  void SetBSplineDomainFromImage( InputFieldType * );
156 
159  { this->SetBSplineDomainFromImage( const_cast<InputFieldType *>( field ) ); }
160 
162  void SetBSplineDomain( OriginType, SpacingType, SizeType, DirectionType );
163 
164  /* Set/Get b-spline domain origin. */
165  itkGetConstMacro( BSplineDomainOrigin, OriginType );
166 
167  /* Set/Get b-spline domain spacing. */
168  itkGetConstMacro( BSplineDomainSpacing, SpacingType );
169 
170  /* Set/Get b-spline domain size. */
171  itkGetConstMacro( BSplineDomainSize, SizeType );
172 
173  /* Set/Get b-spline domain direction. */
174  itkGetConstMacro( BSplineDomainDirection, DirectionType );
175 
176  /* Use input field to define the B-spline doain. */
177  itkSetMacro( UseInputFieldToDefineTheBSplineDomain, bool );
178  itkGetConstMacro( UseInputFieldToDefineTheBSplineDomain, bool )
179  itkBooleanMacro( UseInputFieldToDefineTheBSplineDomain );
180 
184  itkSetMacro( SplineOrder, unsigned int );
185 
189  itkGetConstMacro( SplineOrder, unsigned int );
190 
198  itkSetMacro( NumberOfControlPoints, ArrayType );
199 
207  itkGetConstMacro( NumberOfControlPoints, ArrayType );
208 
215  itkSetMacro( NumberOfFittingLevels, ArrayType );
216 
223  void SetNumberOfFittingLevels( unsigned int n )
224  {
225  ArrayType nlevels;
226 
227  nlevels.Fill( n );
228  this->SetNumberOfFittingLevels( nlevels );
229  }
230 
237  itkGetConstMacro( NumberOfFittingLevels, ArrayType );
238 
242  itkBooleanMacro( EstimateInverse );
243  itkSetMacro( EstimateInverse, bool );
244  itkGetConstMacro( EstimateInverse, bool );
246 
250  itkBooleanMacro( EnforceStationaryBoundary );
251  itkSetMacro( EnforceStationaryBoundary, bool );
252  itkGetConstMacro( EnforceStationaryBoundary, bool );
254 
255 protected:
256 
259 
261  virtual ~DisplacementFieldToBSplineImageFilter() ITK_OVERRIDE;
262 
264  void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
265 
267  void GenerateData() ITK_OVERRIDE;
268 
269 private:
270  ITK_DISALLOW_COPY_AND_ASSIGN(DisplacementFieldToBSplineImageFilter);
271 
272  bool m_EstimateInverse;
273  bool m_EnforceStationaryBoundary;
274  unsigned int m_SplineOrder;
275  ArrayType m_NumberOfControlPoints;
276  ArrayType m_NumberOfFittingLevels;
277 
278  typename WeightsContainerType::Pointer m_PointWeights;
279  bool m_UsePointWeights;
280 
281  OriginType m_BSplineDomainOrigin;
282  SpacingType m_BSplineDomainSpacing;
283  SizeType m_BSplineDomainSize;
284  DirectionType m_BSplineDomainDirection;
285 
286  bool m_BSplineDomainIsDefined;
287  bool m_UseInputFieldToDefineTheBSplineDomain;
288 };
289 
290 } // end namespace itk
291 
292 #ifndef ITK_MANUAL_INSTANTIATION
293 #include "itkDisplacementFieldToBSplineImageFilter.hxx"
294 #endif
295 
296 #endif
const DisplacementFieldControlPointLatticeType * GetDisplacementFieldControlPointLattice() const
Base class for all process objects that output image data.
void Fill(const ValueType &)
BSplineScatteredDataPointSetToImageFilter< InputPointSetType, OutputFieldType > BSplineFilterType
BSplineFilterType::PointDataImageType DisplacementFieldControlPointLatticeType
Image filter which provides a B-spline output approximation.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Base class for filters that take an image as input and produce an image as output.
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Class which takes a dense displacement field image and/or a set of points with associated displacemen...
Templated n-dimensional image class.
Definition: itkImage.h:75
ImageToImageFilter< TInputImage, TOutputImage > Superclass