ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkWarpImageFilter.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 itkWarpImageFilter_h
19 #define itkWarpImageFilter_h
20 #include "itkImageBase.h"
21 #include "itkImageToImageFilter.h"
23 
24 namespace itk
25 {
83 template<
84  typename TInputImage,
85  typename TOutputImage,
86  typename TDisplacementField
87  >
88 class ITK_TEMPLATE_EXPORT WarpImageFilter:
89  public ImageToImageFilter< TInputImage, TOutputImage >
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_ASSIGN(WarpImageFilter);
93 
99 
101  itkNewMacro(Self);
102 
104  itkTypeMacro(WarpImageFilter, ImageToImageFilter);
105 
108 
110  using InputImageType = typename Superclass::InputImageType;
111  using InputImagePointer = typename Superclass::InputImagePointer;
112  using OutputImageType = typename Superclass::OutputImageType;
113  using OutputImagePointer = typename Superclass::OutputImagePointer;
114  using InputImageConstPointer = typename Superclass::InputImageConstPointer;
118  using PixelType = typename OutputImageType::PixelType;
119  using PixelComponentType = typename OutputImageType::InternalPixelType;
120  using SpacingType = typename OutputImageType::SpacingType;
121 
123  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
124  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
125  static constexpr unsigned int DisplacementFieldDimension = TDisplacementField::ImageDimension;
126 
129 
131  using DisplacementFieldType = TDisplacementField;
132  using DisplacementFieldPointer = typename DisplacementFieldType::Pointer;
133  using DisplacementType = typename DisplacementFieldType::PixelType;
134 
136  using CoordRepType = double;
141 
144 
147 
148 
150  itkSetInputMacro(DisplacementField, DisplacementFieldType);
151 
153  itkGetInputMacro(DisplacementField, DisplacementFieldType);
154 
156  itkSetObjectMacro(Interpolator, InterpolatorType);
157  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
159 
161  itkSetMacro(OutputSpacing, SpacingType);
162  virtual void SetOutputSpacing(const double *values);
164 
166  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
167 
169  itkSetMacro(OutputOrigin, PointType);
170  virtual void SetOutputOrigin(const double *values);
172 
174  itkGetConstReferenceMacro(OutputOrigin, PointType);
175 
177  itkSetMacro(OutputDirection, DirectionType);
178  itkGetConstReferenceMacro(OutputDirection, DirectionType);
180 
182  void SetOutputParametersFromImage(const ImageBaseType *image);
183 
186  itkSetMacro(OutputStartIndex, IndexType);
187 
189  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
190 
192  itkSetMacro(OutputSize, SizeType);
193 
195  itkGetConstReferenceMacro(OutputSize, SizeType);
196 
198  itkSetMacro(EdgePaddingValue, PixelType);
199 
201  itkGetConstMacro(EdgePaddingValue, PixelType);
202 
208  void GenerateOutputInformation() override;
209 
216  void GenerateInputRequestedRegion() override;
217 
220  void BeforeThreadedGenerateData() override;
221 
224  void AfterThreadedGenerateData() override;
225 
226 #ifdef ITK_USE_CONCEPT_CHECKING
227  // Begin concept checking
228  itkConceptMacro( SameDimensionCheck1,
230  itkConceptMacro( SameDimensionCheck2,
232  itkConceptMacro( InputHasNumericTraitsCheck,
234  itkConceptMacro( DisplacementFieldHasNumericTraitsCheck,
236  // End concept checking
237 #endif
238 
239 protected:
240  WarpImageFilter();
241  // ~WarpImageFilter() {} default implementation is ok
242 
243  void PrintSelf(std::ostream & os, Indent indent) const override;
244 
248  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
249 
250 
257  void VerifyInputInformation() ITKv5_CONST override;
258 
267  void EvaluateDisplacementAtPhysicalPoint(const PointType & p, DisplacementType & output);
268 
272  void EvaluateDisplacementAtPhysicalPoint(const PointType & p, const DisplacementFieldType * fieldPtr,
273  DisplacementType & output);
274 
275  bool m_DefFieldSameInformation;
276  // variables for deffield interpoator
277  IndexType m_StartIndex, m_EndIndex;
278 
279 private:
280  PixelType m_EdgePaddingValue;
281  SpacingType m_OutputSpacing;
282  PointType m_OutputOrigin;
283  DirectionType m_OutputDirection;
284 
285  InterpolatorPointer m_Interpolator;
286  SizeType m_OutputSize; // Size of the output image
287  IndexType m_OutputStartIndex; // output image start index
288 
289 };
290 } // end namespace itk
291 
292 #ifndef ITK_MANUAL_INSTANTIATION
293 #include "itkWarpImageFilter.hxx"
294 #endif
295 
296 #endif
typename OutputImageType::Pointer OutputImagePointer
typename OutputImageType::SizeType SizeType
typename TOutputImage::DirectionType DirectionType
TDisplacementField DisplacementFieldType
typename DisplacementFieldType::Pointer DisplacementFieldPointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename OutputImageType::IndexType IndexType
Base class for all process objects that output image data.
typename OutputImageType::SpacingType SpacingType
typename InputImageType::Pointer InputImagePointer
typename InterpolatorType::Pointer InterpolatorPointer
typename OutputImageType::IndexValueType IndexValueType
typename OutputImageType::PixelType PixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
signed long IndexValueType
Definition: itkIntTypes.h:90
Warps an image using an input displacement field.
Linearly interpolate an image at specified positions.
typename DisplacementFieldType::PixelType DisplacementType
Base class for all image interpolaters.
Base class for templated image classes.
Definition: itkImageBase.h:105
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
#define itkConceptMacro(name, concept)
typename InputImageType::ConstPointer InputImageConstPointer
typename OutputImageType::InternalPixelType PixelComponentType