18 #ifndef itkNearestNeighborExtrapolateImageFunction_h
19 #define itkNearestNeighborExtrapolateImageFunction_h
40 template <
typename TInputImage,
typename TCoordRep =
float>
60 using typename Superclass::OutputType;
63 using typename Superclass::InputImageType;
66 static constexpr
unsigned int ImageDimension = Superclass::ImageDimension;
73 using typename Superclass::ContinuousIndexType;
87 for (
unsigned int j = 0; j < ImageDimension; ++j)
89 nindex[j] = Math::RoundHalfIntegerUp<IndexValueType>(index[j]);
90 if (nindex[j] < this->GetStartIndex()[j])
92 nindex[j] = this->GetStartIndex()[j];
94 else if (nindex[j] > this->GetEndIndex()[j])
96 nindex[j] = this->GetEndIndex()[j];
99 return static_cast<OutputType>(this->GetInputImage()->GetPixel(nindex));
114 for (
unsigned int j = 0; j < ImageDimension; ++j)
116 if (index[j] < this->GetStartIndex()[j])
118 nindex[j] = this->GetStartIndex()[j];
120 else if (index[j] > this->GetEndIndex()[j])
122 nindex[j] = this->GetEndIndex()[j];
126 nindex[j] = index[j];
129 return static_cast<OutputType>(this->GetInputImage()->GetPixel(nindex));
138 Superclass::PrintSelf(os, indent);