ITK  6.0.0
Insight Toolkit
itkWarpImageFilter.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  * https://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 itkWarpImageFilter_h
19 #define itkWarpImageFilter_h
20 #include "itkImageBase.h"
21 #include "itkImageToImageFilter.h"
23 
24 namespace itk
25 {
84 template <typename TInputImage, typename TOutputImage, typename TDisplacementField>
85 class ITK_TEMPLATE_EXPORT WarpImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(WarpImageFilter);
96 
98  itkNewMacro(Self);
99 
101  itkOverrideGetNameOfClassMacro(WarpImageFilter);
102 
105 
107  using typename Superclass::InputImageType;
108  using typename Superclass::InputImagePointer;
109  using typename Superclass::OutputImageType;
110  using typename Superclass::OutputImagePointer;
111  using typename Superclass::InputImageConstPointer;
115  using PixelType = typename OutputImageType::PixelType;
116  using PixelComponentType = typename OutputImageType::InternalPixelType;
117  using SpacingType = typename OutputImageType::SpacingType;
118 
120  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
121  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
122  static constexpr unsigned int DisplacementFieldDimension = TDisplacementField::ImageDimension;
123 
126 
128  using DisplacementFieldType = TDisplacementField;
130  using DisplacementType = typename DisplacementFieldType::PixelType;
131 
133  using CoordRepType = double;
137 
140 
143 
144 
146  itkSetInputMacro(DisplacementField, DisplacementFieldType);
147 
149  itkGetInputMacro(DisplacementField, DisplacementFieldType);
150 
152  itkSetObjectMacro(Interpolator, InterpolatorType);
153  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
157  itkSetMacro(OutputSpacing, SpacingType);
158  virtual void
159  SetOutputSpacing(const double * spacing);
163  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
164 
166  itkSetMacro(OutputOrigin, PointType);
167  virtual void
168  SetOutputOrigin(const double * origin);
172  itkGetConstReferenceMacro(OutputOrigin, PointType);
173 
175  itkSetMacro(OutputDirection, DirectionType);
176  itkGetConstReferenceMacro(OutputDirection, DirectionType);
180  void
181  SetOutputParametersFromImage(const ImageBaseType * image);
182 
185  itkSetMacro(OutputStartIndex, IndexType);
186 
188  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
189 
191  itkSetMacro(OutputSize, SizeType);
192 
194  itkGetConstReferenceMacro(OutputSize, SizeType);
195 
197  itkSetMacro(EdgePaddingValue, PixelType);
198 
200  itkGetConstMacro(EdgePaddingValue, PixelType);
201 
207  void
208  GenerateOutputInformation() override;
209 
216  void
217  GenerateInputRequestedRegion() override;
218 
221  void
222  BeforeThreadedGenerateData() override;
223 
226  void
227  AfterThreadedGenerateData() override;
228 
229 #ifdef ITK_USE_CONCEPT_CHECKING
230  // Begin concept checking
234  itkConceptMacro(DisplacementFieldHasNumericTraitsCheck,
236  // End concept checking
237 #endif
238 
239 protected:
240  WarpImageFilter();
241  // ~WarpImageFilter() {} default implementation is ok
242 
243  void
244  PrintSelf(std::ostream & os, Indent indent) const override;
245 
249  void
250  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
251 
252 
259  void
260  VerifyInputInformation() const override;
261 
270  void
271  EvaluateDisplacementAtPhysicalPoint(const PointType & point, DisplacementType & output);
272 
276  void
277  EvaluateDisplacementAtPhysicalPoint(const PointType & point,
278  const DisplacementFieldType * fieldPtr,
279  DisplacementType & output);
280 
281  bool m_DefFieldSameInformation{};
282  // variables for deffield interpolator
283  IndexType m_StartIndex, m_EndIndex{};
284 
285 private:
286  PixelType m_EdgePaddingValue{};
287  SpacingType m_OutputSpacing{};
288  PointType m_OutputOrigin{};
289  DirectionType m_OutputDirection{};
290 
291  InterpolatorPointer m_Interpolator{};
292  SizeType m_OutputSize{}; // Size of the output image
293  IndexType m_OutputStartIndex{}; // output image start index
294 };
295 } // end namespace itk
296 
297 #ifndef ITK_MANUAL_INSTANTIATION
298 # include "itkWarpImageFilter.hxx"
299 #endif
300 
301 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:716
itkLinearInterpolateImageFunction.h
itk::WarpImageFilter::m_StartIndex
IndexType m_StartIndex
Definition: itkWarpImageFilter.h:283
itk::WarpImageFilter::DirectionType
typename TOutputImage::DirectionType DirectionType
Definition: itkWarpImageFilter.h:142
itk::ImageBase
Base class for templated image classes.
Definition: itkImageBase.h:114
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::WarpImageFilter::IndexValueType
typename OutputImageType::IndexValueType IndexValueType
Definition: itkWarpImageFilter.h:113
itk::WarpImageFilter::PixelType
typename OutputImageType::PixelType PixelType
Definition: itkWarpImageFilter.h:115
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::Concept::SameDimension
Definition: itkConceptChecking.h:696
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::WarpImageFilter::PixelComponentType
typename OutputImageType::InternalPixelType PixelComponentType
Definition: itkWarpImageFilter.h:116
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::WarpImageFilter::DisplacementType
typename DisplacementFieldType::PixelType DisplacementType
Definition: itkWarpImageFilter.h:130
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:51
itk::WarpImageFilter::DisplacementFieldType
TDisplacementField DisplacementFieldType
Definition: itkWarpImageFilter.h:128
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::WarpImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkWarpImageFilter.h:114
itkImageToImageFilter.h
itk::WarpImageFilter::DisplacementFieldPointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Definition: itkWarpImageFilter.h:129
itk::WarpImageFilter::CoordRepType
double CoordRepType
Definition: itkWarpImageFilter.h:133
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::WarpImageFilter
Warps an image using an input displacement field.
Definition: itkWarpImageFilter.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::WarpImageFilter::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkWarpImageFilter.h:135
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::WarpImageFilter::SpacingType
typename OutputImageType::SpacingType SpacingType
Definition: itkWarpImageFilter.h:117
itk::Point< CoordRepType, Self::ImageDimension >
itk::TransformCategory::DisplacementField
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::WarpImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkWarpImageFilter.h:112
itkImageBase.h