ITK  4.8.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  >
89  public ImageToImageFilter< TInputImage, TOutputImage >
90 {
91 public:
97 
99  itkNewMacro(Self);
100 
103 
105  typedef typename TOutputImage::RegionType OutputImageRegionType;
106 
113  typedef typename OutputImageType::IndexType IndexType;
115  typedef typename OutputImageType::SizeType SizeType;
116  typedef typename OutputImageType::PixelType PixelType;
117  typedef typename OutputImageType::SpacingType SpacingType;
118 
120  itkStaticConstMacro(ImageDimension, unsigned int,
121  TOutputImage::ImageDimension);
122  itkStaticConstMacro(InputImageDimension, unsigned int,
123  TInputImage::ImageDimension);
124  itkStaticConstMacro(DisplacementFieldDimension, unsigned int,
125  TDisplacementField::ImageDimension);
126 
129 
131  typedef TDisplacementField DisplacementFieldType;
132  typedef typename DisplacementFieldType::Pointer DisplacementFieldPointer;
133  typedef typename DisplacementFieldType::PixelType DisplacementType;
134 
135 #ifdef ITKV3_COMPATIBILITY
136  typedef TDisplacementField DeformationFieldType;
137  typedef typename DeformationFieldType::Pointer DeformationFieldPointer;
138  typedef typename DeformationFieldType::PixelType DeformationType;
139 #endif
140 
142  typedef double CoordRepType;
147 
150 
152  typedef typename TOutputImage::DirectionType DirectionType;
153 
155  void SetDisplacementField(const DisplacementFieldType *field);
156 
159 
160 #ifdef ITKV3_COMPATIBILITY
161  void SetDeformationField(const DisplacementFieldType *field)
162  {
163  this->SetDisplacementField(field);
164  }
165  DeformationFieldType * GetDeformationField(void)
166  {
167  return static_cast<DeformationFieldType *> (GetDisplacementField());
168  }
169 #endif
170 
172  itkSetObjectMacro(Interpolator, InterpolatorType);
173  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
175 
177  itkSetMacro(OutputSpacing, SpacingType);
178  virtual void SetOutputSpacing(const double *values);
180 
182  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
183 
185  itkSetMacro(OutputOrigin, PointType);
186  virtual void SetOutputOrigin(const double *values);
188 
190  itkGetConstReferenceMacro(OutputOrigin, PointType);
191 
193  itkSetMacro(OutputDirection, DirectionType);
194  itkGetConstReferenceMacro(OutputDirection, DirectionType);
196 
198  void SetOutputParametersFromImage(const ImageBaseType *image);
199 
202  itkSetMacro(OutputStartIndex, IndexType);
203 
205  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
206 
208  itkSetMacro(OutputSize, SizeType);
209 
211  itkGetConstReferenceMacro(OutputSize, SizeType);
212 
214  itkSetMacro(EdgePaddingValue, PixelType);
215 
217  itkGetConstMacro(EdgePaddingValue, PixelType);
218 
224  virtual void GenerateOutputInformation() ITK_OVERRIDE;
225 
232  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
233 
236  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
237 
240  virtual void AfterThreadedGenerateData() ITK_OVERRIDE;
241 
242 #ifdef ITK_USE_CONCEPT_CHECKING
243  // Begin concept checking
244  itkConceptMacro( SameDimensionCheck1,
245  ( Concept::SameDimension< ImageDimension, InputImageDimension > ) );
246  itkConceptMacro( SameDimensionCheck2,
247  ( Concept::SameDimension< ImageDimension, DisplacementFieldDimension > ) );
248  itkConceptMacro( InputHasNumericTraitsCheck,
249  ( Concept::HasNumericTraits< typename TInputImage::PixelType > ) );
250  itkConceptMacro( DisplacementFieldHasNumericTraitsCheck,
251  ( Concept::HasNumericTraits< typename TDisplacementField::PixelType::ValueType > ) );
252  // End concept checking
253 #endif
254 
255 protected:
256  WarpImageFilter();
257  // ~WarpImageFilter() {} default implementation is ok
258 
259  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
260 
264  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
265  ThreadIdType threadId) ITK_OVERRIDE;
266 
273  virtual void VerifyInputInformation() ITK_OVERRIDE;
274 
279 
281  // variables for deffield interpoator
283 
284 private:
285  WarpImageFilter(const Self &); //purposely not implemented
286  void operator=(const Self &); //purposely not implemented
287 
292 
294  SizeType m_OutputSize; // Size of the output image
295  IndexType m_OutputStartIndex; // output image start index
296 
297 };
298 } // end namespace itk
299 
300 #ifndef ITK_MANUAL_INSTANTIATION
301 #include "itkWarpImageFilter.hxx"
302 #endif
303 
304 #endif
Superclass::InputImageType InputImageType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
InputImageType::ConstPointer InputImageConstPointer
TDisplacementField DisplacementFieldType
InterpolatorPointer m_Interpolator
InputImageType::Pointer InputImagePointer
OutputImageType::SizeType SizeType
signed long IndexValueType
Definition: itkIntTypes.h:150
void EvaluateDisplacementAtPhysicalPoint(const PointType &p, DisplacementType &output)
InterpolateImageFunction< InputImageType, CoordRepType > InterpolatorType
virtual void AfterThreadedGenerateData() override
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
DirectionType m_OutputDirection
OutputImageType::PixelType PixelType
DisplacementFieldType * GetDisplacementField()
TOutputImage::DirectionType DirectionType
OutputImageType::Pointer OutputImagePointer
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
OutputImageType::IndexValueType IndexValueType
virtual void VerifyInputInformation() override
OutputImageType::SpacingType SpacingType
virtual void GenerateOutputInformation() override
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
static const unsigned int InputImageDimension
Base class for all image interpolaters.
Base class for templated image classes.
Definition: itkImageBase.h:112
InterpolatorType::Pointer InterpolatorPointer
void PrintSelf(std::ostream &os, Indent indent) const override
void SetOutputParametersFromImage(const ImageBaseType *image)
Superclass::OutputImagePointer OutputImagePointer
virtual void BeforeThreadedGenerateData() override
LinearInterpolateImageFunction< InputImageType, CoordRepType > DefaultInterpolatorType
Base class for filters that take an image as input and produce an image as output.
static const unsigned int DisplacementFieldDimension
static const unsigned int ImageDimension
virtual void SetOutputOrigin(PointType _arg)
virtual void GenerateInputRequestedRegion() override
TOutputImage OutputImageType
void SetDisplacementField(const DisplacementFieldType *field)
Superclass::OutputImageType OutputImageType
#define itkConceptMacro(name, concept)
Superclass::InputImageConstPointer InputImageConstPointer
virtual void SetOutputSpacing(SpacingType _arg)