ITK  5.1.0
Insight Toolkit
itkResampleImageFilter.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 itkResampleImageFilter_h
19 #define itkResampleImageFilter_h
20 
21 #include "itkFixedArray.h"
22 #include "itkTransform.h"
23 #include "itkImageRegionIterator.h"
24 #include "itkImageToImageFilter.h"
27 #include "itkSize.h"
29 #include "itkDataObjectDecorator.h"
30 
31 
32 namespace itk
33 {
85 template <typename TInputImage,
86  typename TOutputImage,
87  typename TInterpolatorPrecisionType = double,
88  typename TTransformPrecisionType = TInterpolatorPrecisionType>
89 class ITK_TEMPLATE_EXPORT ResampleImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_ASSIGN(ResampleImageFilter);
93 
99 
100  using InputImageType = TInputImage;
101  using OutputImageType = TOutputImage;
102  using InputImagePointer = typename InputImageType::Pointer;
103  using InputImageConstPointer = typename InputImageType::ConstPointer;
104  using OutputImagePointer = typename OutputImageType::Pointer;
106 
108  itkNewMacro(Self);
109 
112 
114  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
115  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
116 
119 
127 
128 
132 
134 
136 
138 
141 
145 
148 
151 
154  // using PointType = typename TOutputImage::PointType;
155 
157  using PixelType = typename TOutputImage::PixelType;
158  using InputPixelType = typename TInputImage::PixelType;
159 
161 
163 
166 
169 
171  using SpacingType = typename TOutputImage::SpacingType;
174 
177 
178  /* See superclass for doxygen. This method adds the additional check
179  * that the output space is set */
180  void
181  VerifyPreconditions() ITKv5_CONST override;
182 
190  itkSetGetDecoratedObjectInputMacro(Transform, TransformType);
191 
199  itkSetObjectMacro(Interpolator, InterpolatorType);
200  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
202 
206  itkSetObjectMacro(Extrapolator, ExtrapolatorType);
207  itkGetModifiableObjectMacro(Extrapolator, ExtrapolatorType);
209 
211  itkSetMacro(Size, SizeType);
212  itkGetConstReferenceMacro(Size, SizeType);
214 
217  itkSetMacro(DefaultPixelValue, PixelType);
218  itkGetConstReferenceMacro(DefaultPixelValue, PixelType);
220 
222  itkSetMacro(OutputSpacing, SpacingType);
223  virtual void
224  SetOutputSpacing(const double * values);
226 
228  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
229 
231  itkSetMacro(OutputOrigin, OriginPointType);
232  virtual void
233  SetOutputOrigin(const double * values);
235 
237  itkGetConstReferenceMacro(OutputOrigin, OriginPointType);
238 
240  itkSetMacro(OutputDirection, DirectionType);
241  itkGetConstReferenceMacro(OutputDirection, DirectionType);
243 
245  void
246  SetOutputParametersFromImage(const ImageBaseType * image);
247 
250  itkSetMacro(OutputStartIndex, IndexType);
251 
253  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
254 
262  itkSetInputMacro(ReferenceImage, ReferenceImageBaseType);
263 
265  itkGetInputMacro(ReferenceImage, ReferenceImageBaseType);
266 
269  itkSetMacro(UseReferenceImage, bool);
270  itkBooleanMacro(UseReferenceImage);
271  itkGetConstMacro(UseReferenceImage, bool);
273 
274 #ifdef ITK_USE_CONCEPT_CHECKING
275  // Begin concept checking
276  itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<PixelComponentType>));
277  // End concept checking
278 #endif
279 
280 protected:
282  ~ResampleImageFilter() override = default;
283  void
284  PrintSelf(std::ostream & os, Indent indent) const override;
285 
291  void
292  VerifyInputInformation() ITKv5_CONST override
293  {}
294 
300  void
301  GenerateOutputInformation() override;
302 
308  void
309  GenerateInputRequestedRegion() override;
310 
314  void
315  BeforeThreadedGenerateData() override;
316 
318  void
319  AfterThreadedGenerateData() override;
320 
323  GetMTime() const override;
324 
334  void
335  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
336 
337 
340  virtual void
341  NonlinearThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
342 
345  virtual void
346  LinearThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
347 
349  itkLegacyMacro(virtual PixelType CastPixelWithBoundsChecking(const InterpolatorOutputType value,
350  const ComponentType minComponent,
351  const ComponentType maxComponent) const);
352 
353 private:
354  static PixelComponentType
355  CastComponentWithBoundsChecking(const PixelComponentType value);
356 
357  template <typename TComponent>
358  static PixelComponentType
359  CastComponentWithBoundsChecking(const TComponent value);
360 
361  static PixelType
362  CastPixelWithBoundsChecking(const ComponentType value);
363 
364  template <typename TPixel>
365  static PixelType
366  CastPixelWithBoundsChecking(const TPixel value);
367 
368  SizeType m_Size; // Size of the output image
370  // interpolation
372  // extrapolation
373  PixelType m_DefaultPixelValue; // default pixel value
374  // if the point is
375  // outside the image
376  SpacingType m_OutputSpacing; // output image spacing
377  OriginPointType m_OutputOrigin; // output image origin
378  DirectionType m_OutputDirection; // output image direction cosines
379  IndexType m_OutputStartIndex; // output image start index
380  bool m_UseReferenceImage{ false };
381 };
382 } // end namespace itk
383 
384 #ifndef ITK_MANUAL_INSTANTIATION
385 # include "itkResampleImageFilter.hxx"
386 #endif
387 
388 #endif
itk::ExtrapolateImageFunction
Base class for all image extrapolaters.
Definition: itkExtrapolateImageFunction.h:43
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:712
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::ResampleImageFilter::m_OutputDirection
DirectionType m_OutputDirection
Definition: itkResampleImageFilter.h:378
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itk::ResampleImageFilter::InterpolatorOutputType
typename InterpolatorType::OutputType InterpolatorOutputType
Definition: itkResampleImageFilter.h:133
itk::Size< Self::ImageDimension >
itkLinearInterpolateImageFunction.h
itk::ResampleImageFilter::PointType
typename InterpolatorType::PointType PointType
Definition: itkResampleImageFilter.h:153
itk::ResampleImageFilter::TransformPointerType
typename TransformType::ConstPointer TransformPointerType
Definition: itkResampleImageFilter.h:124
itk::ImageBase
Base class for templated image classes.
Definition: itkImageBase.h:105
itk::ResampleImageFilter::PixelType
typename TOutputImage::PixelType PixelType
Definition: itkResampleImageFilter.h:157
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::SmartPointer< Self >
itkImageRegionIterator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ResampleImageFilter::m_Extrapolator
ExtrapolatorPointerType m_Extrapolator
Definition: itkResampleImageFilter.h:371
itk::DataObjectDecorator
Decorates any subclass of itkObject with a DataObject API.
Definition: itkDataObjectDecorator.h:66
itk::ResampleImageFilter::PixelComponentType
typename PixelConvertType::ComponentType PixelComponentType
Definition: itkResampleImageFilter.h:162
itk::ResampleImageFilter::IndexType
typename TOutputImage::IndexType IndexType
Definition: itkResampleImageFilter.h:150
itk::ResampleImageFilter::m_Size
SizeType m_Size
Definition: itkResampleImageFilter.h:368
itk::ResampleImageFilter::m_OutputOrigin
OriginPointType m_OutputOrigin
Definition: itkResampleImageFilter.h:377
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
itkDefaultConvertPixelTraits.h
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:49
itk::ResampleImageFilter::VerifyInputInformation
void VerifyInputInformation() ITKv5_CONST override
Definition: itkResampleImageFilter.h:292
itk::ResampleImageFilter::DecoratedTransformPointer
typename DecoratedTransformType::Pointer DecoratedTransformPointer
Definition: itkResampleImageFilter.h:126
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::ResampleImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkResampleImageFilter.h:158
itk::DefaultConvertPixelTraits
Traits class used to by ConvertPixels to convert blocks of pixels.
Definition: itkDefaultConvertPixelTraits.h:41
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkDataObjectDecorator.h
itkFixedArray.h
itkExtrapolateImageFunction.h
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::ResampleImageFilter::OriginPointType
typename TOutputImage::PointType OriginPointType
Definition: itkResampleImageFilter.h:172
itk::ResampleImageFilter::ExtrapolatorPointerType
typename ExtrapolatorType::Pointer ExtrapolatorPointerType
Definition: itkResampleImageFilter.h:144
itk::ResampleImageFilter::DirectionType
typename TOutputImage::DirectionType DirectionType
Definition: itkResampleImageFilter.h:173
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::InterpolateImageFunction::OutputType
typename Superclass::OutputType OutputType
Definition: itkInterpolateImageFunction.h:62
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ResampleImageFilter::m_DefaultPixelValue
PixelType m_DefaultPixelValue
Definition: itkResampleImageFilter.h:373
itk::ContinuousIndex
A templated class holding a point in n-Dimensional image space.
Definition: itkContinuousIndex.h:46
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:135
itk::ResampleImageFilter::m_Interpolator
InterpolatorPointerType m_Interpolator
Definition: itkResampleImageFilter.h:369
itk::ResampleImageFilter::ComponentType
typename InterpolatorConvertType::ComponentType ComponentType
Definition: itkResampleImageFilter.h:137
itk::ResampleImageFilter
Resample an image via a coordinate transform.
Definition: itkResampleImageFilter.h:89
itk::ResampleImageFilter::m_OutputSpacing
SpacingType m_OutputSpacing
Definition: itkResampleImageFilter.h:376
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:81
itkTransform.h
itk::ResampleImageFilter::SpacingType
typename TOutputImage::SpacingType SpacingType
Definition: itkResampleImageFilter.h:171
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ResampleImageFilter::m_OutputStartIndex
IndexType m_OutputStartIndex
Definition: itkResampleImageFilter.h:379
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:44
itk::DefaultConvertPixelTraits::ComponentType
typename PixelType::ComponentType ComponentType
Definition: itkDefaultConvertPixelTraits.h:45
itk::ImageToImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::ResampleImageFilter::InterpolatorPointerType
typename InterpolatorType::Pointer InterpolatorPointerType
Definition: itkResampleImageFilter.h:131
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itkSize.h
itk::ResampleImageFilter::LinearInterpolatorPointerType
typename LinearInterpolatorType::Pointer LinearInterpolatorPointerType
Definition: itkResampleImageFilter.h:140