diff --git a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h index f8158e83e68..ac6b90ec427 100644 --- a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h +++ b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h @@ -21,6 +21,7 @@ #include "itkConstNeighborhoodIterator.h" #include "itkZeroFluxNeumannBoundaryCondition.h" #include "itkInterpolateImageFunction.h" +#include "itkMath.h" namespace itk { @@ -326,8 +327,8 @@ class ITK_TEMPLATE_EXPORT WindowedSincInterpolateImageFunction : public Interpol } protected: - WindowedSincInterpolateImageFunction(); - ~WindowedSincInterpolateImageFunction() override; + WindowedSincInterpolateImageFunction() = default; + ~WindowedSincInterpolateImageFunction() override = default; void PrintSelf(std::ostream & os, Indent indent) const override; @@ -336,20 +337,20 @@ class ITK_TEMPLATE_EXPORT WindowedSincInterpolateImageFunction : public Interpol using IteratorType = ConstNeighborhoodIterator; // Constant to store twice the radius - static const unsigned int m_WindowSize; + static constexpr unsigned int m_WindowSize{ 2 * VRadius }; /** The function object, used to compute window */ TWindowFunction m_WindowFunction; + /** Size of the offset table */ + static constexpr unsigned int m_OffsetTableSize{ Math::UnsignedPower(m_WindowSize, ImageDimension) }; + /** The offset array, used to keep a list of relevant * offsets in the neihborhoodIterator */ - unsigned int * m_OffsetTable; - - /** Size of the offset table */ - unsigned int m_OffsetTableSize; + unsigned int m_OffsetTable[m_OffsetTableSize]; /** Index into the weights array for each offset */ - unsigned int ** m_WeightOffsetTable; + unsigned int m_WeightOffsetTable[m_OffsetTableSize][ImageDimension]; /** The sinc function */ inline double diff --git a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx index 32a96d888df..b2810fca25c 100644 --- a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx @@ -45,62 +45,6 @@ template const double BlackmanWindowFunction::m_Factor2 = 2.0 * itk::Math::pi / VRadius; } // end namespace Function -/** Window size constant */ -template -const unsigned int - WindowedSincInterpolateImageFunction:: - m_WindowSize = VRadius << 1; - -/** Constructor */ -template -WindowedSincInterpolateImageFunction:: - WindowedSincInterpolateImageFunction() -{ - // Compute the offset table size - m_OffsetTableSize = 1; - for (unsigned int dim = 0; dim < ImageDimension; ++dim) - { - m_OffsetTableSize *= m_WindowSize; - } - - // Allocate the offset table - m_OffsetTable = new unsigned int[m_OffsetTableSize]; - - // Allocate the weights tables - m_WeightOffsetTable = new unsigned int *[m_OffsetTableSize]; - for (unsigned int i = 0; i < m_OffsetTableSize; ++i) - { - m_WeightOffsetTable[i] = new unsigned int[ImageDimension]; - } -} - -/** Destructor */ -template -WindowedSincInterpolateImageFunction:: - ~WindowedSincInterpolateImageFunction() -{ - // Clear the offset table - delete[] m_OffsetTable; - - // Clear the weights tables - for (unsigned int i = 0; i < m_OffsetTableSize; ++i) - { - delete[] m_WeightOffsetTable[i]; - } - delete[] m_WeightOffsetTable; -} template