ITK  5.4.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  * 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 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_MOVE(NearestNeighborInterpolateImageFunction);
44 
50 
52  itkOverrideGetNameOfClassMacro(NearestNeighborInterpolateImageFunction);
53 
55  itkNewMacro(Self);
56 
58  using typename Superclass::OutputType;
59 
61  using typename Superclass::InputImageType;
62 
64  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
65 
67  using typename Superclass::IndexType;
68 
70  using typename Superclass::SizeType;
71 
73  using 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::ImageFunction< TInputImage, NumericTraits< TInputImage::PixelType >::RealType, TCoordRep >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:90
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, TInputImage::ImageDimension >, NumericTraits< TInputImage::PixelType >::RealType >::OutputType
NumericTraits< TInputImage::PixelType >::RealType OutputType
Definition: itkFunctionBase.h:62
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:55
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::ContinuousIndex< TCoordRep, Self::ImageDimension >
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