ITK  5.2.0
Insight Toolkit
itkDisplacementFieldToBSplineImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 : public ImageToImageFilter<TInputImage, TOutputImage>
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_MOVE(DisplacementFieldToBSplineImageFilter);
48 
53 
55  itkNewMacro(Self);
56 
58  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
59 
60  using InputFieldType = TInputImage;
61  using InputPointSetType = TInputPointSet;
62  using OutputFieldType = TOutputImage;
63 
67 
69  using PixelType = typename OutputFieldType::PixelType;
70  using VectorType = typename OutputFieldType::PixelType;
73 
74  using SpacingType = typename OutputFieldType::SpacingType;
78 
79  using RealType = typename VectorType::RealValueType;
81 
84  using PointDataType = typename InputPointSetType::PixelType;
85  using PointsContainerType = typename InputPointSetType::PointsContainer;
86  using PointDataContainerType = typename InputPointSetType::PointDataContainer;
87 
93 
95  void
97  {
98  this->SetInput(0, field);
99  }
100 
102  const InputFieldType *
104  {
105  return this->GetInput(0);
106  }
107 
113  void
115  {
116  this->SetNthInput(1, const_cast<RealImageType *>(image));
117  }
118  void
119  SetInput1(const RealImageType * image)
120  {
121  this->SetConfidenceImage(image);
122  }
124 
126  const RealImageType *
128  {
129  return static_cast<const RealImageType *>(this->ProcessObject::GetInput(1));
130  }
131 
133  void
135  {
136  this->SetNthInput(2, const_cast<InputPointSetType *>(points));
137  }
138  void
139  SetInput2(const InputPointSetType * points)
140  {
141  this->SetPointSet(points);
142  }
144 
146  const InputPointSetType *
147  GetPointSet() const
148  {
149  return static_cast<const InputPointSetType *>(this->ProcessObject::GetInput(2));
150  }
151 
153  void
154  SetPointSetConfidenceWeights(WeightsContainerType * weights);
155 
157  const DisplacementFieldControlPointLatticeType *
159  {
160  return static_cast<const DisplacementFieldControlPointLatticeType *>(this->GetOutput(1));
161  }
162 
164  void
165  SetBSplineDomainFromImage(RealImageType *);
166 
168  void
170  {
171  this->SetBSplineDomainFromImage(const_cast<RealImageType *>(image));
172  }
173 
175  void
176  SetBSplineDomainFromImage(InputFieldType *);
177 
179  void
181  {
182  this->SetBSplineDomainFromImage(const_cast<InputFieldType *>(field));
183  }
184 
186  void SetBSplineDomain(OriginType, SpacingType, SizeType, DirectionType);
187 
188  /* Set/Get b-spline domain origin. */
189  itkGetConstMacro(BSplineDomainOrigin, OriginType);
190 
191  /* Set/Get b-spline domain spacing. */
192  itkGetConstMacro(BSplineDomainSpacing, SpacingType);
193 
194  /* Set/Get b-spline domain size. */
195  itkGetConstMacro(BSplineDomainSize, SizeType);
196 
197  /* Set/Get b-spline domain direction. */
198  itkGetConstMacro(BSplineDomainDirection, DirectionType);
199 
200  /* Use input field to define the B-spline doain. */
201  itkSetMacro(UseInputFieldToDefineTheBSplineDomain, bool);
202  itkGetConstMacro(UseInputFieldToDefineTheBSplineDomain, bool);
203  itkBooleanMacro(UseInputFieldToDefineTheBSplineDomain);
204 
208  itkSetMacro(SplineOrder, unsigned int);
209 
213  itkGetConstMacro(SplineOrder, unsigned int);
214 
222  itkSetMacro(NumberOfControlPoints, ArrayType);
223 
231  itkGetConstMacro(NumberOfControlPoints, ArrayType);
232 
239  itkSetMacro(NumberOfFittingLevels, ArrayType);
240 
247  void
248  SetNumberOfFittingLevels(unsigned int n)
249  {
250  ArrayType nlevels;
251 
252  nlevels.Fill(n);
253  this->SetNumberOfFittingLevels(nlevels);
254  }
255 
262  itkGetConstMacro(NumberOfFittingLevels, ArrayType);
263 
267  itkBooleanMacro(EstimateInverse);
268  itkSetMacro(EstimateInverse, bool);
269  itkGetConstMacro(EstimateInverse, bool);
271 
275  itkBooleanMacro(EnforceStationaryBoundary);
276  itkSetMacro(EnforceStationaryBoundary, bool);
277  itkGetConstMacro(EnforceStationaryBoundary, bool);
279 
280 protected:
283 
285  ~DisplacementFieldToBSplineImageFilter() override = default;
286 
288  void
289  PrintSelf(std::ostream & os, Indent indent) const override;
290 
292  void
293  GenerateData() override;
294 
295 private:
296  bool m_EstimateInverse{ false };
297  bool m_EnforceStationaryBoundary{ true };
298  unsigned int m_SplineOrder{ 3 };
301 
302  typename WeightsContainerType::Pointer m_PointWeights;
303  bool m_UsePointWeights{ false };
304 
309 
310  bool m_BSplineDomainIsDefined{ true };
311  bool m_UseInputFieldToDefineTheBSplineDomain{ false };
312 };
313 
314 } // end namespace itk
315 
316 #ifndef ITK_MANUAL_INSTANTIATION
317 # include "itkDisplacementFieldToBSplineImageFilter.hxx"
318 #endif
319 
320 #endif
itk::DisplacementFieldToBSplineImageFilter::PointType
typename InputPointSetType::PointType PointType
Definition: itkDisplacementFieldToBSplineImageFilter.h:83
itk::DisplacementFieldToBSplineImageFilter::IndexType
typename OutputFieldType::IndexType IndexType
Definition: itkDisplacementFieldToBSplineImageFilter.h:72
itk::DisplacementFieldToBSplineImageFilter::RegionType
typename OutputFieldType::RegionType RegionType
Definition: itkDisplacementFieldToBSplineImageFilter.h:71
itk::DisplacementFieldToBSplineImageFilter::SpacingType
typename OutputFieldType::SpacingType SpacingType
Definition: itkDisplacementFieldToBSplineImageFilter.h:74
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::DisplacementFieldToBSplineImageFilter::SetBSplineDomainFromImage
void SetBSplineDomainFromImage(const RealImageType *image)
Definition: itkDisplacementFieldToBSplineImageFilter.h:169
itk::DisplacementFieldToBSplineImageFilter::SetInput1
void SetInput1(const RealImageType *image)
Definition: itkDisplacementFieldToBSplineImageFilter.h:119
itk::DisplacementFieldToBSplineImageFilter::InputFieldPointType
typename InputFieldType::PointType InputFieldPointType
Definition: itkDisplacementFieldToBSplineImageFilter.h:66
itk::DisplacementFieldToBSplineImageFilter::m_BSplineDomainOrigin
OriginType m_BSplineDomainOrigin
Definition: itkDisplacementFieldToBSplineImageFilter.h:305
itk::DisplacementFieldToBSplineImageFilter::SetPointSet
void SetPointSet(const InputPointSetType *points)
Definition: itkDisplacementFieldToBSplineImageFilter.h:134
itk::DisplacementFieldToBSplineImageFilter::m_BSplineDomainDirection
DirectionType m_BSplineDomainDirection
Definition: itkDisplacementFieldToBSplineImageFilter.h:308
itk::DisplacementFieldToBSplineImageFilter::SetInput2
void SetInput2(const InputPointSetType *points)
Definition: itkDisplacementFieldToBSplineImageFilter.h:139
itk::DisplacementFieldToBSplineImageFilter::OriginType
typename OutputFieldType::PointType OriginType
Definition: itkDisplacementFieldToBSplineImageFilter.h:75
itk::DisplacementFieldToBSplineImageFilter::PointsContainerType
typename InputPointSetType::PointsContainer PointsContainerType
Definition: itkDisplacementFieldToBSplineImageFilter.h:85
itk::DisplacementFieldToBSplineImageFilter::SizeType
typename OutputFieldType::SizeType SizeType
Definition: itkDisplacementFieldToBSplineImageFilter.h:76
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::BSplineScatteredDataPointSetToImageFilter
Image filter which provides a B-spline output approximation.
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:132
itk::DisplacementFieldToBSplineImageFilter::GetDisplacementField
const InputFieldType * GetDisplacementField() const
Definition: itkDisplacementFieldToBSplineImageFilter.h:103
itk::DisplacementFieldToBSplineImageFilter
Class which takes a dense displacement field image and/or a set of points with associated displacemen...
Definition: itkDisplacementFieldToBSplineImageFilter.h:44
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::DisplacementFieldToBSplineImageFilter::GetPointSet
const InputPointSetType * GetPointSet() const
Definition: itkDisplacementFieldToBSplineImageFilter.h:147
itk::DisplacementFieldToBSplineImageFilter::DisplacementFieldControlPointLatticeType
typename BSplineFilterType::PointDataImageType DisplacementFieldControlPointLatticeType
Definition: itkDisplacementFieldToBSplineImageFilter.h:91
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DisplacementFieldToBSplineImageFilter::PointDataType
typename InputPointSetType::PixelType PointDataType
Definition: itkDisplacementFieldToBSplineImageFilter.h:84
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::DisplacementFieldToBSplineImageFilter::m_NumberOfFittingLevels
ArrayType m_NumberOfFittingLevels
Definition: itkDisplacementFieldToBSplineImageFilter.h:300
itk::DisplacementFieldToBSplineImageFilter::GetDisplacementFieldControlPointLattice
const DisplacementFieldControlPointLatticeType * GetDisplacementFieldControlPointLattice() const
Definition: itkDisplacementFieldToBSplineImageFilter.h:158
itk::DisplacementFieldToBSplineImageFilter::m_NumberOfControlPoints
ArrayType m_NumberOfControlPoints
Definition: itkDisplacementFieldToBSplineImageFilter.h:299
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::DisplacementFieldToBSplineImageFilter::m_BSplineDomainSpacing
SpacingType m_BSplineDomainSpacing
Definition: itkDisplacementFieldToBSplineImageFilter.h:306
itk::DisplacementFieldToBSplineImageFilter::InputFieldType
TInputImage InputFieldType
Definition: itkDisplacementFieldToBSplineImageFilter.h:60
itk::DisplacementFieldToBSplineImageFilter::PixelType
typename OutputFieldType::PixelType PixelType
Definition: itkDisplacementFieldToBSplineImageFilter.h:69
itkBSplineScatteredDataPointSetToImageFilter.h
itk::DisplacementFieldToBSplineImageFilter::DirectionType
typename OutputFieldType::DirectionType DirectionType
Definition: itkDisplacementFieldToBSplineImageFilter.h:77
itk::DisplacementFieldToBSplineImageFilter::m_BSplineDomainSize
SizeType m_BSplineDomainSize
Definition: itkDisplacementFieldToBSplineImageFilter.h:307
itk::DisplacementFieldToBSplineImageFilter::InputPointSetType
TInputPointSet InputPointSetType
Definition: itkDisplacementFieldToBSplineImageFilter.h:61
itkImageToImageFilter.h
itk::FixedArray< unsigned, Self::ImageDimension >
itk::DisplacementFieldToBSplineImageFilter::m_PointWeights
WeightsContainerType::Pointer m_PointWeights
Definition: itkDisplacementFieldToBSplineImageFilter.h:302
itk::DisplacementFieldToBSplineImageFilter::SetBSplineDomainFromImage
void SetBSplineDomainFromImage(const InputFieldType *field)
Definition: itkDisplacementFieldToBSplineImageFilter.h:180
itk::DisplacementFieldToBSplineImageFilter::RealType
typename VectorType::RealValueType RealType
Definition: itkDisplacementFieldToBSplineImageFilter.h:79
itk::DisplacementFieldToBSplineImageFilter::WeightsContainerType
typename BSplineFilterType::WeightsContainerType WeightsContainerType
Definition: itkDisplacementFieldToBSplineImageFilter.h:90
itk::DisplacementFieldToBSplineImageFilter::SetConfidenceImage
void SetConfidenceImage(const RealImageType *image)
Definition: itkDisplacementFieldToBSplineImageFilter.h:114
itk::DisplacementFieldToBSplineImageFilter::GetConfidenceImage
const RealImageType * GetConfidenceImage() const
Definition: itkDisplacementFieldToBSplineImageFilter.h:127
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DisplacementFieldToBSplineImageFilter::VectorType
typename OutputFieldType::PixelType VectorType
Definition: itkDisplacementFieldToBSplineImageFilter.h:70
itk::DisplacementFieldToBSplineImageFilter::PointDataContainerType
typename InputPointSetType::PointDataContainer PointDataContainerType
Definition: itkDisplacementFieldToBSplineImageFilter.h:86
itk::DisplacementFieldToBSplineImageFilter::InverseDisplacementFieldType
OutputFieldType InverseDisplacementFieldType
Definition: itkDisplacementFieldToBSplineImageFilter.h:65
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itkVector.h
itk::DisplacementFieldToBSplineImageFilter::SetDisplacementField
void SetDisplacementField(const InputFieldType *field)
Definition: itkDisplacementFieldToBSplineImageFilter.h:96
itk::DisplacementFieldToBSplineImageFilter::ArrayType
typename BSplineFilterType::ArrayType ArrayType
Definition: itkDisplacementFieldToBSplineImageFilter.h:92
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::DisplacementFieldToBSplineImageFilter::OutputFieldType
TOutputImage OutputFieldType
Definition: itkDisplacementFieldToBSplineImageFilter.h:62
itkPointSet.h
itk::DisplacementFieldToBSplineImageFilter::SetNumberOfFittingLevels
void SetNumberOfFittingLevels(unsigned int n)
Definition: itkDisplacementFieldToBSplineImageFilter.h:248
itk::DisplacementFieldToBSplineImageFilter::DisplacementFieldType
InputFieldType DisplacementFieldType
Definition: itkDisplacementFieldToBSplineImageFilter.h:64
itk::VectorContainer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
Definition: itkVectorContainer.h:48
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.