Skip to content

Commit

Permalink
STYLE: Removed LinearInterpolateImageFunction::m_Neighbors
Browse files Browse the repository at this point in the history
LinearInterpolateImageFunction has a private static const data member
'm_Neighbors' that is only used once, within EvaluateUnoptimized.
This commit removes m_Neighbors. Instead, the number of neighbors
is now computed at compile-time, within EvaluateUnoptimized, storing
the value into a local constexpr variable.

This commit may reduce the runtime overhead somewhat, but it's mostly
a style improvement, simplifying the code.

Change-Id: I96649e11a543fc0f3f246e1f5023ebbc855c520e
  • Loading branch information
N-Dekker committed Sep 4, 2018
1 parent cac022a commit 452126b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ class ITK_TEMPLATE_EXPORT LinearInterpolateImageFunction:
void PrintSelf(std::ostream & os, Indent indent) const override;

private:
/** Number of neighbors used in the interpolation */
static const unsigned long m_Neighbors;

struct DispatchBase {};
template< unsigned int >
struct Dispatch: public DispatchBase {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@

namespace itk
{

// Define the number of neighbors
template< typename TInputImage, typename TCoordRep >
const unsigned long
LinearInterpolateImageFunction< TInputImage, TCoordRep >
::m_Neighbors = 1 << TInputImage::ImageDimension;


template< typename TInputImage, typename TCoordRep >
LinearInterpolateImageFunction< TInputImage, TCoordRep >
::LinearInterpolateImageFunction()
Expand Down Expand Up @@ -80,7 +72,10 @@ LinearInterpolateImageFunction< TInputImage, TCoordRep >

Concept::Detail::UniqueType< typename NumericTraits< InputPixelType >::ScalarRealType >();

for ( unsigned int counter = 0; counter < m_Neighbors; ++counter )
// Number of neighbors used in the interpolation
constexpr unsigned long numberOfNeighbors = 1 << TInputImage::ImageDimension;

for ( unsigned int counter = 0; counter < numberOfNeighbors; ++counter )
{
InternalComputationType overlap = 1.0; // Fraction overlap
unsigned int upper = counter; // Each bit indicates upper/lower neighbour
Expand Down

0 comments on commit 452126b

Please sign in to comment.