4 #include <vnl/vnl_math.h> 12 template<
class TInputImage,
class TCoordRep>
14 VectorModelLinearInterpolateImageFunction< TInputImage, TCoordRep >
15 ::m_Neighbors = 1 << TInputImage::ImageDimension;
21 template<
class TInputImage,
class TCoordRep>
31 template<
class TInputImage,
class TCoordRep>
38 double distance[ImageDimension], oppDistance[ImageDimension];
40 for (
unsigned int dim = 0; dim < ImageDimension; ++dim)
42 baseIndex[dim] = itk::Math::Floor< IndexValueType >( index[dim] );
43 distance[dim] = index[dim] -
static_cast< double >( baseIndex[dim] );
44 oppDistance[dim] = 1.0 - distance[dim];
47 unsigned int vectorDim = this->GetInputImage()->GetNumberOfComponentsPerPixel();
49 this->InitializeZeroPixel(output);
51 double totalOverlap = 0;
53 for(
unsigned int counter = 0; counter < m_Neighbors; ++counter)
56 unsigned int upper = counter;
61 for (
unsigned int dim = 0; dim < ImageDimension; ++dim)
65 neighIndex[dim] = baseIndex[dim] + 1;
67 if (neighIndex[dim] > this->m_EndIndex[dim])
73 overlap *= distance[dim];
77 neighIndex[dim] = baseIndex[dim];
79 if (neighIndex[dim] < this->m_StartIndex[dim])
85 overlap *= oppDistance[dim];
92 if ((overlap > 0) && okValue)
98 this->AddValue(input,overlap,output);
99 totalOverlap += overlap;
105 if (totalOverlap >= 0.5)
106 output /= totalOverlap;
108 this->InitializeZeroPixel(output);
Superclass::IndexType IndexType
VectorModelLinearInterpolateImageFunction()
virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &index) const ITK_OVERRIDE
Superclass::OutputType OutputType
itk::VariableLengthVector< typename TInputImage::IOPixelType > VectorPixelType
Superclass::ContinuousIndexType ContinuousIndexType