ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkNearestNeighborInterpolateImageFunction.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 itkNearestNeighborInterpolateImageFunction_h
19 #define itkNearestNeighborInterpolateImageFunction_h
20 
22 
23 namespace itk
24 {
37 template< typename TInputImage, typename TCoordRep = double >
38 class ITK_TEMPLATE_EXPORT NearestNeighborInterpolateImageFunction:
39  public InterpolateImageFunction< TInputImage, TCoordRep >
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_ASSIGN(NearestNeighborInterpolateImageFunction);
43 
49 
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 ContinuousIndexType = typename Superclass::ContinuousIndexType;
71 
81  const ContinuousIndexType & index) const override
82  {
83  IndexType nindex;
84 
85  this->ConvertContinuousIndexToNearestIndex(index, nindex);
86  return static_cast< OutputType >( this->GetInputImage()->GetPixel(nindex) );
87  }
88 
89 protected:
91  ~NearestNeighborInterpolateImageFunction() override = default;
92  void PrintSelf(std::ostream & os, Indent indent) const override
93  { Superclass::PrintSelf(os, indent); }
94 };
95 } // end namespace itk
96 
97 #endif
Light weight base class for most itk classes.
typename Superclass::ContinuousIndexType ContinuousIndexType
typename Superclass::OutputType OutputType
Nearest neighbor interpolation of a scalar image.
typename Superclass::IndexType IndexType
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for all image interpolaters.
typename Superclass::InputImageType InputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override