ITK  5.4.0
Insight Toolkit
itkInterpolateImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 itkInterpolateImageFunction_h
19 #define itkInterpolateImageFunction_h
20 
21 #include "itkImageFunction.h"
22 
23 namespace itk
24 {
44 template <typename TInputImage, typename TCoordRep = double>
45 class ITK_TEMPLATE_EXPORT InterpolateImageFunction
46  : public ImageFunction<TInputImage, typename NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_MOVE(InterpolateImageFunction);
50 
53  using Superclass =
55 
58 
60  itkOverrideGetNameOfClassMacro(InterpolateImageFunction);
61 
63  using typename Superclass::OutputType;
64 
66  using typename Superclass::InputImageType;
67 
69  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
70 
72  using typename Superclass::PointType;
73 
75  using typename Superclass::IndexType;
76  using typename Superclass::IndexValueType;
77 
80 
82  using typename Superclass::ContinuousIndexType;
83 
86 
96  Evaluate(const PointType & point) const override
97  {
98  const ContinuousIndexType index =
99  this->GetInputImage()->template TransformPhysicalPointToContinuousIndex<TCoordRep>(point);
100  return (this->EvaluateAtContinuousIndex(index));
101  }
114  OutputType
115  EvaluateAtContinuousIndex(const ContinuousIndexType & index) const override = 0;
116 
125  OutputType
126  EvaluateAtIndex(const IndexType & index) const override
127  {
128  return (static_cast<RealType>(this->GetInputImage()->GetPixel(index)));
129  }
130 
136 #if defined(ITKV4_COMPATIBILITY)
137  virtual SizeType
138  GetRadius() const
139  {
140  // if ITKv4 compatibility is enabled then set the radius to the
141  // largest by default.
142  const InputImageType * input = this->GetInputImage();
143  if (!input)
144  {
145  itkExceptionMacro("Input image required!");
146  }
147  return input->GetLargestPossibleRegion().GetSize();
148  }
149 #else
150  virtual SizeType
151  GetRadius() const = 0;
152 #endif
153 
155 protected:
156  InterpolateImageFunction() = default;
157  ~InterpolateImageFunction() override = default;
158  void
159  PrintSelf(std::ostream & os, Indent indent) const override
160  {
161  Superclass::PrintSelf(os, indent);
162  }
163 };
164 } // end namespace itk
165 
166 #endif
itkImageFunction.h
itk::InterpolateImageFunction< TImageType, TCoordRep >::SizeType
typename InputImageType::SizeType SizeType
Definition: itkInterpolateImageFunction.h:79
itk::ImageFunction< TImageType, NumericTraits< TImageType ::PixelType >::RealType, TCoordRep >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:90
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::InterpolateImageFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkInterpolateImageFunction.h:159
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::FunctionBase< Point< TCoordRep, TImageType ::ImageDimension >, NumericTraits< TImageType ::PixelType >::RealType >::OutputType
NumericTraits< TImageType ::PixelType >::RealType OutputType
Definition: itkFunctionBase.h:62
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:90
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageFunction
Evaluates a function of an image at specified position.
Definition: itkImageFunction.h:55
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::InterpolateImageFunction::EvaluateAtIndex
OutputType EvaluateAtIndex(const IndexType &index) const override
Definition: itkInterpolateImageFunction.h:126
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ContinuousIndex< TCoordRep, Self::ImageDimension >
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:85
itk::InterpolateImageFunction::Evaluate
OutputType Evaluate(const PointType &point) const override
Definition: itkInterpolateImageFunction.h:96
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::InterpolateImageFunction< TImageType, TCoordRep >::RealType
typename NumericTraits< typename TImageType ::PixelType >::RealType RealType
Definition: itkInterpolateImageFunction.h:85