ITK  5.0.0
Insight Segmentation and Registration 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 :
90  public ImageToImageFilter< TInputImage, TOutputImage >
91 {
92 public:
93  ITK_DISALLOW_COPY_AND_ASSIGN(ResampleImageFilter);
94 
100 
101  using InputImageType = TInputImage;
102  using OutputImageType = TOutputImage;
103  using InputImagePointer = typename InputImageType::Pointer;
104  using InputImageConstPointer = typename InputImageType::ConstPointer;
105  using OutputImagePointer = typename OutputImageType::Pointer;
107 
109  itkNewMacro(Self);
110 
113 
115  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
116  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
117 
120 
124  using TransformType = Transform< TTransformPrecisionType,
125  Self::ImageDimension,
126  Self::ImageDimension >;
130 
131 
134  TInterpolatorPrecisionType >;
136 
138 
140 
142 
144  TInterpolatorPrecisionType >;
146 
149  TInterpolatorPrecisionType >;
151 
154 
157 
160  //using PointType = typename TOutputImage::PointType;
161 
163  using PixelType = typename TOutputImage::PixelType;
164  using InputPixelType = typename TInputImage::PixelType;
165 
167 
169 
173 
176 
178  using SpacingType = typename TOutputImage::SpacingType;
181 
184 
192  itkSetGetDecoratedObjectInputMacro(Transform, TransformType);
193 
201  itkSetObjectMacro(Interpolator, InterpolatorType);
202  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
204 
208  itkSetObjectMacro(Extrapolator, ExtrapolatorType);
209  itkGetModifiableObjectMacro(Extrapolator, ExtrapolatorType);
211 
213  itkSetMacro(Size, SizeType);
214  itkGetConstReferenceMacro(Size, SizeType);
216 
219  itkSetMacro(DefaultPixelValue, PixelType);
220  itkGetConstReferenceMacro(DefaultPixelValue, PixelType);
222 
224  itkSetMacro(OutputSpacing, SpacingType);
225  virtual void SetOutputSpacing(const double *values);
227 
229  itkGetConstReferenceMacro(OutputSpacing, SpacingType);
230 
232  itkSetMacro(OutputOrigin, OriginPointType);
233  virtual void SetOutputOrigin(const double *values);
235 
237  itkGetConstReferenceMacro(OutputOrigin, OriginPointType);
238 
240  itkSetMacro(OutputDirection, DirectionType);
241  itkGetConstReferenceMacro(OutputDirection, DirectionType);
243 
245  void SetOutputParametersFromImage(const ImageBaseType *image);
246 
249  itkSetMacro(OutputStartIndex, IndexType);
250 
252  itkGetConstReferenceMacro(OutputStartIndex, IndexType);
253 
260  itkSetInputMacro(ReferenceImage, ReferenceImageBaseType);
261 
263  itkGetInputMacro(ReferenceImage, ReferenceImageBaseType);
264 
267  itkSetMacro(UseReferenceImage, bool);
268  itkBooleanMacro(UseReferenceImage);
269  itkGetConstMacro(UseReferenceImage, bool);
271 
272 #ifdef ITK_USE_CONCEPT_CHECKING
273  // Begin concept checking
274  itkConceptMacro( OutputHasNumericTraitsCheck,
276  // End concept checking
277 #endif
278 
279 protected:
281  ~ResampleImageFilter() override = default;
282  void PrintSelf(std::ostream & os, Indent indent) const override;
283 
289  void VerifyInputInformation() ITKv5_CONST override { }
290 
296  void GenerateOutputInformation() override;
297 
303  void GenerateInputRequestedRegion() override;
304 
308  void BeforeThreadedGenerateData() override;
309 
311  void AfterThreadedGenerateData() override;
312 
314  ModifiedTimeType GetMTime() const override;
315 
325  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
326 
327 
330  virtual void NonlinearThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
331 
334  virtual void LinearThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
335 
337  itkLegacyMacro(
338  virtual PixelType CastPixelWithBoundsChecking( const InterpolatorOutputType value,
339  const ComponentType minComponent,
340  const ComponentType maxComponent) const);
341 
342 private:
343  static PixelComponentType CastComponentWithBoundsChecking(const PixelComponentType value);
344 
345  template <typename TComponent>
346  static PixelComponentType CastComponentWithBoundsChecking(const TComponent value);
347 
348  static PixelType CastPixelWithBoundsChecking(const ComponentType value);
349 
350  template <typename TPixel>
351  static PixelType CastPixelWithBoundsChecking(const TPixel value);
352 
353  SizeType m_Size; // Size of the output image
355  // interpolation
357  // extrapolation
358  PixelType m_DefaultPixelValue; // default pixel value
359  // if the point is
360  // outside the image
361  SpacingType m_OutputSpacing; // output image spacing
362  OriginPointType m_OutputOrigin; // output image origin
363  DirectionType m_OutputDirection; // output image direction cosines
364  IndexType m_OutputStartIndex; // output image start index
365  bool m_UseReferenceImage{ false };
366 
367 };
368 } // end namespace itk
369 
370 #ifndef ITK_MANUAL_INSTANTIATION
371 #include "itkResampleImageFilter.hxx"
372 #endif
373 
374 #endif
typename OutputImageType::Pointer OutputImagePointer
typename TransformType::ConstPointer TransformPointerType
InterpolatorPointerType m_Interpolator
typename TOutputImage::IndexType IndexType
Resample an image via a coordinate transform.
typename Superclass::OutputType OutputType
Traits class used to by ConvertPixels to convert blocks of pixels.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename InterpolatorType::PointType PointType
Base class for all process objects that output image data.
typename DecoratedTransformType::Pointer DecoratedTransformPointer
typename TOutputImage::PixelType PixelType
typename InterpolatorType::Pointer InterpolatorPointerType
typename PixelConvertType::ComponentType PixelComponentType
typename InputImageType::Pointer InputImagePointer
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
typename TOutputImage::PointType OriginPointType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
Decorates any subclass of itkObject with a DataObject API.
void VerifyInputInformation() ITKv5_CONST override
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:104
Linearly interpolate an image at specified positions.
Base class for all image interpolaters.
typename InputImageType::RegionType InputImageRegionType
Base class for templated image classes.
Definition: itkImageBase.h:105
A templated class holding a point in n-Dimensional image space.
Base class for all image extrapolaters.
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
ExtrapolatorPointerType m_Extrapolator
typename TOutputImage::SpacingType SpacingType
typename PixelType::ComponentType ComponentType
typename InterpolatorType::OutputType InterpolatorOutputType
typename TOutputImage::DirectionType DirectionType
typename InterpolatorConvertType::ComponentType ComponentType
typename TInputImage::PixelType InputPixelType
#define itkConceptMacro(name, concept)
typename ExtrapolatorType::Pointer ExtrapolatorPointerType
typename InputImageType::ConstPointer InputImageConstPointer
typename LinearInterpolatorType::Pointer LinearInterpolatorPointerType