ITK  4.13.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:
97 
99  itkNewMacro(Self);
100 
103 
105  typedef typename TOutputImage::RegionType OutputImageRegionType;
106 
108  typedef typename Superclass::InputImageType InputImageType;
109  typedef typename Superclass::InputImagePointer InputImagePointer;
110  typedef typename Superclass::OutputImageType OutputImageType;
111  typedef typename Superclass::OutputImagePointer OutputImagePointer;
112  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
116  typedef typename OutputImageType::PixelType PixelType;
117  typedef typename OutputImageType::InternalPixelType PixelComponentType;
118  typedef typename OutputImageType::SpacingType SpacingType;
119 
121  itkStaticConstMacro(ImageDimension, unsigned int,
122  TOutputImage::ImageDimension);
123  itkStaticConstMacro(InputImageDimension, unsigned int,
124  TInputImage::ImageDimension);
125  itkStaticConstMacro(DisplacementFieldDimension, unsigned int,
126  TDisplacementField::ImageDimension);
127 
130 
132  typedef TDisplacementField DisplacementFieldType;
133  typedef typename DisplacementFieldType::Pointer DisplacementFieldPointer;
134  typedef typename DisplacementFieldType::PixelType DisplacementType;
135 
136 #ifdef ITKV3_COMPATIBILITY
137  typedef TDisplacementField DeformationFieldType;
138  typedef typename DeformationFieldType::Pointer DeformationFieldPointer;
139  typedef typename DeformationFieldType::PixelType DeformationType;
140 #endif
141 
143  typedef double CoordRepType;
148 
151 
154 
155 
157  itkSetInputMacro(DisplacementField, DisplacementFieldType);
158 
160  itkGetInputMacro(DisplacementField, DisplacementFieldType);
161 
162 #ifdef ITKV3_COMPATIBILITY
163  void SetDeformationField(const DisplacementFieldType *field)
164  {
165  this->SetDisplacementField(field);
166  }
167  DeformationFieldType * GetDeformationField(void)
168  {
169  return const_cast<DeformationFieldType *> (GetDisplacementField());
170  }
171 #endif
172 
174  itkSetObjectMacro(Interpolator, InterpolatorType);
175  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
177 
179  itkSetMacro(OutputSpacing, SpacingType);
180  virtual void SetOutputSpacing(const double *values);
182 
184  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
185 
187  itkSetMacro(OutputOrigin, PointType);
188  virtual void SetOutputOrigin(const double *values);
190 
192  itkGetConstReferenceMacro(OutputOrigin, PointType);
193 
195  itkSetMacro(OutputDirection, DirectionType);
196  itkGetConstReferenceMacro(OutputDirection, DirectionType);
198 
200  void SetOutputParametersFromImage(const ImageBaseType *image);
201 
204  itkSetMacro(OutputStartIndex, IndexType);
205 
207  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
208 
210  itkSetMacro(OutputSize, SizeType);
211 
213  itkGetConstReferenceMacro(OutputSize, SizeType);
214 
216  itkSetMacro(EdgePaddingValue, PixelType);
217 
219  itkGetConstMacro(EdgePaddingValue, PixelType);
220 
226  virtual void GenerateOutputInformation() ITK_OVERRIDE;
227 
234  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
235 
238  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
239 
242  virtual void AfterThreadedGenerateData() ITK_OVERRIDE;
243 
244 #ifdef ITK_USE_CONCEPT_CHECKING
245  // Begin concept checking
246  itkConceptMacro( SameDimensionCheck1,
247  ( Concept::SameDimension< ImageDimension, InputImageDimension > ) );
248  itkConceptMacro( SameDimensionCheck2,
249  ( Concept::SameDimension< ImageDimension, DisplacementFieldDimension > ) );
250  itkConceptMacro( InputHasNumericTraitsCheck,
251  ( Concept::HasNumericTraits< typename TInputImage::InternalPixelType > ) );
252  itkConceptMacro( DisplacementFieldHasNumericTraitsCheck,
253  ( Concept::HasNumericTraits< typename TDisplacementField::PixelType::ValueType > ) );
254  // End concept checking
255 #endif
256 
257 protected:
258  WarpImageFilter();
259  // ~WarpImageFilter() {} default implementation is ok
260 
261  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
262 
266  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
267  ThreadIdType threadId) ITK_OVERRIDE;
268 
275  virtual void VerifyInputInformation() ITK_OVERRIDE;
276 
285  void EvaluateDisplacementAtPhysicalPoint(const PointType & p, DisplacementType & output);
286 
290  void EvaluateDisplacementAtPhysicalPoint(const PointType & p, const DisplacementFieldType * fieldPtr,
291  DisplacementType & output);
292 
293  bool m_DefFieldSameInformation;
294  // variables for deffield interpoator
295  IndexType m_StartIndex, m_EndIndex;
296 
297 private:
298  ITK_DISALLOW_COPY_AND_ASSIGN(WarpImageFilter);
299 
300  PixelType m_EdgePaddingValue;
301  SpacingType m_OutputSpacing;
302  PointType m_OutputOrigin;
303  DirectionType m_OutputDirection;
304 
305  InterpolatorPointer m_Interpolator;
306  SizeType m_OutputSize; // Size of the output image
307  IndexType m_OutputStartIndex; // output image start index
308 
309 };
310 } // end namespace itk
311 
312 #ifndef ITK_MANUAL_INSTANTIATION
313 #include "itkWarpImageFilter.hxx"
314 #endif
315 
316 #endif
Superclass::InputImageType InputImageType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
TDisplacementField DisplacementFieldType
OutputImageType::InternalPixelType PixelComponentType
OutputImageType::SizeType SizeType
signed long IndexValueType
Definition: itkIntTypes.h:150
InterpolateImageFunction< InputImageType, CoordRepType > InterpolatorType
SmartPointer< const Self > ConstPointer
TOutputImage::RegionType OutputImageRegionType
OutputImageType::IndexType IndexType
Base class for all process objects that output image data.
SmartPointer< Self > Pointer
ImageBase< itkGetStaticConstMacro(ImageDimension) > ImageBaseType
Superclass::InputImagePointer InputImagePointer
DisplacementFieldType::PixelType DisplacementType
OutputImageType::PixelType PixelType
TOutputImage::DirectionType DirectionType
OutputImageType::IndexValueType IndexValueType
OutputImageType::SpacingType SpacingType
Warps an image using an input displacement field.
DisplacementFieldType::Pointer DisplacementFieldPointer
Linearly interpolate an image at specified positions.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
Point< CoordRepType, itkGetStaticConstMacro(ImageDimension) > PointType
Base class for all image interpolaters.
Base class for templated image classes.
Definition: itkImageBase.h:114
InterpolatorType::Pointer InterpolatorPointer
Superclass::OutputImagePointer OutputImagePointer
LinearInterpolateImageFunction< InputImageType, CoordRepType > DefaultInterpolatorType
Base class for filters that take an image as input and produce an image as output.
Superclass::OutputImageType OutputImageType
#define itkConceptMacro(name, concept)
Superclass::InputImageConstPointer InputImageConstPointer