18 #ifndef __itkLinearInterpolateImageFunction_h
19 #define __itkLinearInterpolateImageFunction_h
47 template<
typename TInputImage,
typename TCoordRep =
double >
114 template<
unsigned int >
127 basei[0] = Math::Floor< IndexValueType >(index[0]);
135 const TInputImage *
const inputImagePtr = this->
GetInputImage();
136 const RealType & val0 = inputImagePtr->GetPixel(basei);
137 if ( distance <= 0. )
139 return ( static_cast< OutputType >( val0 ) );
145 return ( static_cast< OutputType >( val0 ) );
147 const RealType & val1 = inputImagePtr->GetPixel(basei);
149 return ( static_cast< OutputType >( val0 + ( val1 - val0 ) * distance ) );
157 basei[0] = Math::Floor< IndexValueType >(index[0]);
164 basei[1] = Math::Floor< IndexValueType >(index[1]);
171 const TInputImage *
const inputImagePtr = this->
GetInputImage();
172 const RealType & val00 = inputImagePtr->GetPixel(basei);
173 if ( distance0 <= 0. && distance1 <= 0. )
175 return ( static_cast< OutputType >( val00 ) );
177 else if ( distance1 <= 0. )
182 return ( static_cast< OutputType >( val00 ) );
184 const RealType & val10 = inputImagePtr->GetPixel(basei);
185 return ( static_cast< OutputType >( val00 + ( val10 - val00 ) * distance0 ) );
187 else if ( distance0 <= 0. )
192 return ( static_cast< OutputType >( val00 ) );
194 const RealType & val01 = inputImagePtr->GetPixel(basei);
195 return ( static_cast< OutputType >( val00 + ( val01 - val00 ) * distance1 ) );
206 return ( static_cast< OutputType >( val00 ) );
208 const RealType & val01 = inputImagePtr->GetPixel(basei);
209 return ( static_cast< OutputType >( val00 + ( val01 - val00 ) * distance1 ) );
211 const RealType & val10 = inputImagePtr->GetPixel(basei);
213 const RealType & valx0 = val00 + ( val10 - val00 ) * distance0;
218 return ( static_cast< OutputType >( valx0 ) );
220 const RealType & val11 = inputImagePtr->GetPixel(basei);
222 const RealType & val01 = inputImagePtr->GetPixel(basei);
224 const RealType & valx1 = val01 + ( val11 - val01 ) * distance0;
226 return ( static_cast< OutputType >( valx0 + ( valx1 - valx0 ) * distance1 ) );
233 basei[0] = Math::Floor< IndexValueType >(index[0]);
240 basei[1] = Math::Floor< IndexValueType >(index[1]);
247 basei[2] = Math::Floor< IndexValueType >(index[2]);
254 const TInputImage *
const inputImagePtr = this->
GetInputImage();
255 const RealType & val000 = inputImagePtr->GetPixel(basei);
256 if ( distance0 <= 0. && distance1 <= 0. && distance2 <= 0. )
258 return ( static_cast< OutputType >( val000 ) );
261 if ( distance2 <= 0. )
263 if ( distance1 <= 0. )
268 return ( static_cast< OutputType >( val000 ) );
270 const RealType & val100 = inputImagePtr->GetPixel(basei);
272 return static_cast< OutputType >( val000 + ( val100 - val000 ) * distance0 );
274 else if ( distance0 <= 0. )
279 return ( static_cast< OutputType >( val000 ) );
281 const RealType & val010 = inputImagePtr->GetPixel(basei);
283 return static_cast< OutputType >( val000 + ( val010 - val000 ) * distance1 );
294 return ( static_cast< OutputType >( val000 ) );
296 const RealType & val010 = inputImagePtr->GetPixel(basei);
297 return static_cast< OutputType >( val000 + ( val010 - val000 ) * distance1 );
299 const RealType & val100 = inputImagePtr->GetPixel(basei);
300 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
305 return ( static_cast< OutputType >( valx00 ) );
307 const RealType & val110 = inputImagePtr->GetPixel(basei);
310 const RealType & val010 = inputImagePtr->GetPixel(basei);
311 const RealType & valx10 = val010 + ( val110 - val010 ) * distance0;
313 return static_cast< OutputType >( valx00 + ( valx10 - valx00 ) * distance1 );
318 if ( distance1 <= 0. )
320 if ( distance0 <= 0. )
325 return ( static_cast< OutputType >( val000 ) );
327 const RealType & val001 = inputImagePtr->GetPixel(basei);
329 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
340 return ( static_cast< OutputType >( val000 ) );
342 const RealType & val001 = inputImagePtr->GetPixel(basei);
344 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
346 const RealType & val100 = inputImagePtr->GetPixel(basei);
348 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
353 return ( static_cast< OutputType >( valx00 ) );
355 const RealType & val101 = inputImagePtr->GetPixel(basei);
358 const RealType & val001 = inputImagePtr->GetPixel(basei);
360 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
362 return static_cast< OutputType >( valx00 + ( valx01 - valx00 ) * distance2 );
365 else if ( distance0 <= 0. )
374 return ( static_cast< OutputType >( val000 ) );
376 const RealType & val001 = inputImagePtr->GetPixel(basei);
378 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
380 const RealType & val010 = inputImagePtr->GetPixel(basei);
382 const RealType & val0x0 = val000 + ( val010 - val000 ) * distance1;
387 return ( static_cast< OutputType >( val0x0 ) );
389 const RealType & val011 = inputImagePtr->GetPixel(basei);
392 const RealType & val001 = inputImagePtr->GetPixel(basei);
394 const RealType & val0x1 = val001 + ( val011 - val001 ) * distance1;
396 return static_cast< OutputType >( val0x0 + ( val0x1 - val0x0 ) * distance2 );
411 return ( static_cast< OutputType >( val000 ) );
413 const RealType & val001 = inputImagePtr->GetPixel(basei);
415 return static_cast< OutputType >( val000 + ( val001 - val000 ) * distance2 );
417 const RealType & val010 = inputImagePtr->GetPixel(basei);
418 const RealType & val0x0 = val000 + ( val010 - val000 ) * distance1;
423 return ( static_cast< OutputType >( val0x0 ) );
425 const RealType & val011 = inputImagePtr->GetPixel(basei);
428 const RealType & val001 = inputImagePtr->GetPixel(basei);
430 const RealType & val0x1 = val001 + ( val011 - val001 ) * distance1;
432 return static_cast< OutputType >( val0x0 + ( val0x1 - val0x0 ) * distance2 );
434 const RealType & val100 = inputImagePtr->GetPixel(basei);
436 const RealType & valx00 = val000 + ( val100 - val000 ) * distance0;
445 return ( static_cast< OutputType >( valx00 ) );
447 const RealType & val101 = inputImagePtr->GetPixel(basei);
450 const RealType & val001 = inputImagePtr->GetPixel(basei);
452 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
454 return static_cast< OutputType >( valx00 + ( valx01 - valx00 ) * distance2 );
456 const RealType & val110 = inputImagePtr->GetPixel(basei);
459 const RealType & val010 = inputImagePtr->GetPixel(basei);
461 const RealType & valx10 = val010 + ( val110 - val010 ) * distance0;
463 const RealType & valxx0 = valx00 + ( valx10 - valx00 ) * distance1;
468 return ( static_cast< OutputType >( valxx0 ) );
470 const RealType & val011 = inputImagePtr->GetPixel(basei);
473 const RealType & val111 = inputImagePtr->GetPixel(basei);
476 const RealType & val101 = inputImagePtr->GetPixel(basei);
479 const RealType & val001 = inputImagePtr->GetPixel(basei);
481 const RealType & valx01 = val001 + ( val101 - val001 ) * distance0;
482 const RealType & valx11 = val011 + ( val111 - val011 ) * distance0;
483 const RealType & valxx1 = valx01 + ( valx11 - valx01 ) * distance1;
485 return ( static_cast< OutputType >( valxx0 + ( valxx1 - valxx0 ) * distance2 ) );
501 #ifndef ITK_MANUAL_INSTANTIATION
502 #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()
SmartPointer< Self > Pointer
Superclass::ContinuousIndexType ContinuousIndexType
LinearInterpolateImageFunction Self
virtual OutputType EvaluateUnoptimized(const ContinuousIndexType &index) const
ContinuousIndexType::ValueType InternalComputationType
void PrintSelf(std::ostream &os, Indent indent) const
Superclass::IndexType IndexType
virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &index) const
Superclass::OutputType OutputType
const InputImageType * GetInputImage() const
static const unsigned int ImageDimension
InputImageType::PixelType InputPixelType
void operator=(const Self &)
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.
OutputType EvaluateOptimized(const Dispatch< 1 > &, const ContinuousIndexType &index) const
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