ITK  5.1.0
Insight Toolkit
itkInterpolateImageFunction.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 itkInterpolateImageFunction_h
19 #define itkInterpolateImageFunction_h
20 
21 #include "itkImageFunction.h"
22 
23 namespace itk
24 {
43 template <typename TInputImage, typename TCoordRep = double>
44 class ITK_TEMPLATE_EXPORT InterpolateImageFunction
45  : public ImageFunction<TInputImage, typename NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_ASSIGN(InterpolateImageFunction);
49 
52  using Superclass =
54 
57 
60 
62  using OutputType = typename Superclass::OutputType;
63 
65  using InputImageType = typename Superclass::InputImageType;
66 
68  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
69 
71  using PointType = typename Superclass::PointType;
72 
74  using IndexType = typename Superclass::IndexType;
76 
79 
81  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
82 
85 
95  Evaluate(const PointType & point) const override
96  {
97  ContinuousIndexType index;
98 
99  this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
100  return (this->EvaluateAtContinuousIndex(index));
101  }
102 
113  OutputType
114  EvaluateAtContinuousIndex(const ContinuousIndexType & index) const override = 0;
115 
124  OutputType
125  EvaluateAtIndex(const IndexType & index) const override
126  {
127  return (static_cast<RealType>(this->GetInputImage()->GetPixel(index)));
128  }
129 
135 #if defined(ITKV4_COMPATIBILITY)
136  virtual SizeType
137  GetRadius() const
138  {
139  // if ITKv4 compatibility is enabled then set the radius to the
140  // largest by default.
141  const InputImageType * input = this->GetInputImage();
142  if (!input)
143  {
144  itkExceptionMacro("Input image required!");
145  }
146  return input->GetLargestPossibleRegion().GetSize();
147  }
148 #else
149  virtual SizeType
150  GetRadius() const = 0;
151 #endif
152 
153 
154 protected:
155  InterpolateImageFunction() = default;
156  ~InterpolateImageFunction() override = default;
157  void
158  PrintSelf(std::ostream & os, Indent indent) const override
159  {
160  Superclass::PrintSelf(os, indent);
161  }
162 };
163 } // end namespace itk
164 
165 #endif
itkImageFunction.h
itk::InterpolateImageFunction< TImageType, TCoordRep >::SizeType
typename InputImageType::SizeType SizeType
Definition: itkInterpolateImageFunction.h:78
itk::ImageFunction< TImageType, NumericTraits< TImageType ::PixelType >::RealType, TCoordRep >::InputImageType
TImageType InputImageType
Definition: itkImageFunction.h:74
itk::ImageFunction< TImageType, NumericTraits< TImageType ::PixelType >::RealType, TCoordRep >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:89
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:158
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::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:54
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::InterpolateImageFunction::EvaluateAtIndex
OutputType EvaluateAtIndex(const IndexType &index) const override
Definition: itkInterpolateImageFunction.h:125
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ContinuousIndex< TCoordRep, Self::ImageDimension >
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:84
itk::InterpolateImageFunction::Evaluate
OutputType Evaluate(const PointType &point) const override
Definition: itkInterpolateImageFunction.h:95
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:44
itk::ImageFunction< TImageType, NumericTraits< TImageType ::PixelType >::RealType, TCoordRep >::IndexValueType
typename InputImageType::IndexValueType IndexValueType
Definition: itkImageFunction.h:90
itk::InterpolateImageFunction< TImageType, TCoordRep >::RealType
typename NumericTraits< typename TImageType ::PixelType >::RealType RealType
Definition: itkInterpolateImageFunction.h:84