ITK  5.2.0
Insight Toolkit
itkNearestNeighborInterpolateImageFunction.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  * 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 itkNearestNeighborInterpolateImageFunction_h
19 #define itkNearestNeighborInterpolateImageFunction_h
20 
22 
23 namespace itk
24 {
38 template <typename TInputImage, typename TCoordRep = double>
39 class ITK_TEMPLATE_EXPORT NearestNeighborInterpolateImageFunction
40  : public InterpolateImageFunction<TInputImage, TCoordRep>
41 {
42 public:
43  ITK_DISALLOW_COPY_AND_ASSIGN(NearestNeighborInterpolateImageFunction);
44 
50 
53 
55  itkNewMacro(Self);
56 
58  using OutputType = typename Superclass::OutputType;
59 
61  using InputImageType = typename Superclass::InputImageType;
62 
64  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
65 
67  using IndexType = typename Superclass::IndexType;
68 
70  using SizeType = typename Superclass::SizeType;
71 
73  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
74 
84  EvaluateAtContinuousIndex(const ContinuousIndexType & index) const override
85  {
86  IndexType nindex;
87 
88  this->ConvertContinuousIndexToNearestIndex(index, nindex);
89  return static_cast<OutputType>(this->GetInputImage()->GetPixel(nindex));
90  }
91 
92  SizeType
93  GetRadius() const override
94  {
95  return SizeType(); // zeroes by default
96  }
97 
98 protected:
100  ~NearestNeighborInterpolateImageFunction() override = default;
101  void
102  PrintSelf(std::ostream & os, Indent indent) const override
103  {
104  Superclass::PrintSelf(os, indent);
105  }
106 };
107 } // end namespace itk
108 
109 #endif
itk::InterpolateImageFunction::SizeType
typename InputImageType::SizeType SizeType
Definition: itkInterpolateImageFunction.h:79
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::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::InterpolateImageFunction::ContinuousIndexType
typename Superclass::ContinuousIndexType ContinuousIndexType
Definition: itkInterpolateImageFunction.h:82
itk::InterpolateImageFunction::InputImageType
typename Superclass::InputImageType InputImageType
Definition: itkInterpolateImageFunction.h:66
itk::InterpolateImageFunction::OutputType
typename Superclass::OutputType OutputType
Definition: itkInterpolateImageFunction.h:63
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::NearestNeighborInterpolateImageFunction::EvaluateAtContinuousIndex
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override
Definition: itkNearestNeighborInterpolateImageFunction.h:84
itk::NearestNeighborInterpolateImageFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkNearestNeighborInterpolateImageFunction.h:102
itk::NearestNeighborInterpolateImageFunction
Nearest neighbor interpolation of a scalar image.
Definition: itkNearestNeighborInterpolateImageFunction.h:39
itkInterpolateImageFunction.h
itk::NearestNeighborInterpolateImageFunction::GetRadius
SizeType GetRadius() const override
Definition: itkNearestNeighborInterpolateImageFunction.h:93
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::InterpolateImageFunction::IndexType
typename Superclass::IndexType IndexType
Definition: itkInterpolateImageFunction.h:75