18 #ifndef itkLinearInterpolateImageFunction_h
19 #define itkLinearInterpolateImageFunction_h
48 template<
typename TInputImage,
typename TCoordRep =
double >
97 index)
const ITK_OVERRIDE
109 void operator=(const
Self &) ITK_DELETE_FUNCTION;
115 template<
unsigned int >
128 basei[0] = Math::Floor< IndexValueType >(index[0]);
136 const TInputImage *
const inputImagePtr = this->
GetInputImage();
137 const RealType & val0 = inputImagePtr->GetPixel(basei);
138 if ( distance <= 0. )
140 return ( static_cast< OutputType >( val0 ) );
146 return ( static_cast< OutputType >( val0 ) );
148 const RealType & val1 = inputImagePtr->GetPixel(basei);
150 return ( static_cast< OutputType >( val0 + ( val1 - val0 ) * distance ) );
158 basei[0] = Math::Floor< IndexValueType >(index[0]);
165 basei[1] = Math::Floor< IndexValueType >(index[1]);
172 const TInputImage *
const inputImagePtr = this->
GetInputImage();
173 const RealType & val00 = inputImagePtr->GetPixel(basei);
174 if ( distance0 <= 0. && distance1 <= 0. )
176 return ( static_cast< OutputType >( val00 ) );
178 else if ( distance1 <= 0. )
183 return ( static_cast< OutputType >( val00 ) );
185 const RealType & val10 = inputImagePtr->GetPixel(basei);
186 return ( static_cast< OutputType >( val00 + ( val10 - val00 ) * distance0 ) );
188 else if ( distance0 <= 0. )
193 return ( static_cast< OutputType >( val00 ) );
195 const RealType & val01 = inputImagePtr->GetPixel(basei);
196 return ( static_cast< OutputType >( val00 + ( val01 - val00 ) * distance1 ) );
207 return ( static_cast< OutputType >( val00 ) );
209 const RealType & val01 = inputImagePtr->GetPixel(basei);
210 return ( static_cast< OutputType >( val00 + ( val01 - val00 ) * distance1 ) );
212 const RealType & val10 = inputImagePtr->GetPixel(basei);
214 const RealType & valx0 = val00 + ( val10 - val00 ) * distance0;
219 return ( static_cast< OutputType >( valx0 ) );
221 const RealType & val11 = inputImagePtr->GetPixel(basei);
223 const RealType & val01 = inputImagePtr->GetPixel(basei);
225 const RealType & valx1 = val01 + ( val11 - val01 ) * distance0;
227 return ( static_cast< OutputType >( valx0 + ( valx1 - valx0 ) * distance1 ) );
234 basei[0] = Math::Floor< IndexValueType >(index[0]);
241 basei[1] = Math::Floor< IndexValueType >(index[1]);
248 basei[2] = Math::Floor< IndexValueType >(index[2]);
255 const TInputImage *
const inputImagePtr = this->
GetInputImage();
256 const RealType & val000 = inputImagePtr->GetPixel(basei);
257 if ( distance0 <= 0. && distance1 <= 0. && distance2 <= 0. )
259 return ( static_cast< OutputType >( val000 ) );
262 if ( distance2 <= 0. )
264 if ( distance1 <= 0. )
269 return ( static_cast< OutputType >( val000 ) );
271 const RealType & val100 = inputImagePtr->GetPixel(basei);
273 return static_cast< OutputType >( val000 + ( val100 - val000 ) * distance0 );
275 else if ( distance0 <= 0. )
280 return ( static_cast< OutputType >( val000 ) );
282 const RealType & val010 = inputImagePtr->GetPixel(basei);
284 return static_cast< OutputType >( val000 + ( val010 - val000 ) * distance1 );
295 return ( static_cast< OutputType >( val000 ) );
297 const RealType & val010 = inputImagePtr->GetPixel(basei);
298 return static_cast< OutputType >( val000 + ( val010 - val000 ) * distance1 );
300 const RealType & val100 = inputImagePtr->GetPixel(basei);
301 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
306 return ( static_cast< OutputType >( valx00 ) );
308 const RealType & val110 = inputImagePtr->GetPixel(basei);
311 const RealType & val010 = inputImagePtr->GetPixel(basei);
312 const RealType & valx10 = val010 + ( val110 - val010 ) * distance0;
314 return static_cast< OutputType >( valx00 + ( valx10 - valx00 ) * distance1 );
319 if ( distance1 <= 0. )
321 if ( distance0 <= 0. )
326 return ( static_cast< OutputType >( val000 ) );
328 const RealType & val001 = inputImagePtr->GetPixel(basei);
330 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
341 return ( static_cast< OutputType >( val000 ) );
343 const RealType & val001 = inputImagePtr->GetPixel(basei);
345 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
347 const RealType & val100 = inputImagePtr->GetPixel(basei);
349 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
354 return ( static_cast< OutputType >( valx00 ) );
356 const RealType & val101 = inputImagePtr->GetPixel(basei);
359 const RealType & val001 = inputImagePtr->GetPixel(basei);
361 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
363 return static_cast< OutputType >( valx00 + ( valx01 - valx00 ) * distance2 );
366 else if ( distance0 <= 0. )
375 return ( static_cast< OutputType >( val000 ) );
377 const RealType & val001 = inputImagePtr->GetPixel(basei);
379 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
381 const RealType & val010 = inputImagePtr->GetPixel(basei);
383 const RealType & val0x0 = val000 + ( val010 - val000 ) * distance1;
388 return ( static_cast< OutputType >( val0x0 ) );
390 const RealType & val011 = inputImagePtr->GetPixel(basei);
393 const RealType & val001 = inputImagePtr->GetPixel(basei);
395 const RealType & val0x1 = val001 + ( val011 - val001 ) * distance1;
397 return static_cast< OutputType >( val0x0 + ( val0x1 - val0x0 ) * distance2 );
412 return ( static_cast< OutputType >( val000 ) );
414 const RealType & val001 = inputImagePtr->GetPixel(basei);
416 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
418 const RealType & val010 = inputImagePtr->GetPixel(basei);
419 const RealType & val0x0 = val000 + ( val010 - val000 ) * distance1;
424 return ( static_cast< OutputType >( val0x0 ) );
426 const RealType & val011 = inputImagePtr->GetPixel(basei);
429 const RealType & val001 = inputImagePtr->GetPixel(basei);
431 const RealType & val0x1 = val001 + ( val011 - val001 ) * distance1;
433 return static_cast< OutputType >( val0x0 + ( val0x1 - val0x0 ) * distance2 );
435 const RealType & val100 = inputImagePtr->GetPixel(basei);
437 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
446 return ( static_cast< OutputType >( valx00 ) );
448 const RealType & val101 = inputImagePtr->GetPixel(basei);
451 const RealType & val001 = inputImagePtr->GetPixel(basei);
453 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
455 return static_cast< OutputType >( valx00 + ( valx01 - valx00 ) * distance2 );
457 const RealType & val110 = inputImagePtr->GetPixel(basei);
460 const RealType & val010 = inputImagePtr->GetPixel(basei);
462 const RealType & valx10 = val010 + ( val110 - val010 ) * distance0;
464 const RealType & valxx0 = valx00 + ( valx10 - valx00 ) * distance1;
469 return ( static_cast< OutputType >( valxx0 ) );
471 const RealType & val011 = inputImagePtr->GetPixel(basei);
474 const RealType & val111 = inputImagePtr->GetPixel(basei);
477 const RealType & val101 = inputImagePtr->GetPixel(basei);
480 const RealType & val001 = inputImagePtr->GetPixel(basei);
482 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
483 const RealType & valx11 = val011 + ( val111 - val011 ) * distance0;
484 const RealType & valxx1 = valx01 + ( valx11 - valx01 ) * distance1;
486 return ( static_cast< OutputType >( valxx0 + ( valxx1 - valxx0 ) * distance2 ) );
502 template<
typename RealTypeScalarRealType>
508 typename TInputImage::IndexType idx;
510 const typename TInputImage::PixelType & tempPixel = inputImagePtr->GetPixel(idx);
511 const unsigned int sizeOfVarLengthVector = tempPixel.GetSize();
512 tempZeros.
SetSize(sizeOfVarLengthVector);
516 template<
typename RealTypeScalarRealType>
519 RealTypeScalarRealType & tempZeros)
const
528 #ifndef ITK_MANUAL_INSTANTIATION
529 #include "itkLinearInterpolateImageFunction.hxx"
static const unsigned int ImageDimension
OutputType EvaluateOptimized(const DispatchBase &, const ContinuousIndexType &index) const
Light weight base class for most itk classes.
~LinearInterpolateImageFunction()
void MakeZeroInitializer(const TInputImage *const , RealTypeScalarRealType &tempZeros) const
SmartPointer< Self > Pointer
Superclass::ContinuousIndexType ContinuousIndexType
virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override
void PrintSelf(std::ostream &os, Indent indent) const override
LinearInterpolateImageFunction Self
void MakeZeroInitializer(const TInputImage *const inputImagePtr, VariableLengthVector< RealTypeScalarRealType > &tempZeros) const
A method to generically set all components to zero.
virtual OutputType EvaluateUnoptimized(const ContinuousIndexType &index) const
ContinuousIndexType::ValueType InternalComputationType
Superclass::IndexType IndexType
Superclass::OutputType OutputType
const InputImageType * GetInputImage() const
void Fill(TValue const &v) noexcept
static const unsigned int ImageDimension
Represents an array whose length can be defined at run-time.
InputImageType::PixelType InputPixelType
Superclass::InputImageType InputImageType
Linearly interpolate an image at specified positions.
Superclass::IndexType IndexType
LinearInterpolateImageFunction()
SmartPointer< const Self > ConstPointer
Superclass::ContinuousIndexType ContinuousIndexType
Base class for all image interpolaters.
Superclass::InputImageType InputImageType
Superclass::InputPixelType InputPixelType
Superclass::OutputType OutputType
static const unsigned long m_Neighbors
Control indentation during Print() invocation.
Define additional traits for native types such as int or float.
OutputType EvaluateOptimized(const Dispatch< 1 > &, const ContinuousIndexType &index) const
void SetSize(unsigned int sz, TReallocatePolicy reallocatePolicy, TKeepValuesPolicy keepValues)
OutputType EvaluateOptimized(const Dispatch< 0 > &, const ContinuousIndexType &) const
OutputType EvaluateOptimized(const Dispatch< 3 > &, const ContinuousIndexType &index) const
InterpolateImageFunction< TInputImage, TCoordRep > Superclass
Superclass::RealType RealType
OutputType EvaluateOptimized(const Dispatch< 2 > &, const ContinuousIndexType &index) const
NumericTraits< typename TInputImage::PixelType >::RealType RealType