diff --git a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h index b0a2be4e4d2..dc55964d335 100644 --- a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h +++ b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.h @@ -25,6 +25,7 @@ namespace itk { +// clang-format off namespace Function { /** @@ -41,12 +42,10 @@ class ITK_TEMPLATE_EXPORT CosineWindowFunction inline TOutput operator()(const TInput & A) const { - return static_cast(std::cos(A * m_Factor)); + /** Equal to \f$ \frac{\pi}{2 m} \f$ */ + static constexpr double factor = Math::pi / (2 * VRadius); + return static_cast(std::cos(A * factor)); } - -private: - /** Equal to \f$ \frac{\pi}{2 m} \f$ */ - static const double m_Factor; }; /** @@ -63,12 +62,10 @@ class ITK_TEMPLATE_EXPORT HammingWindowFunction inline TOutput operator()(const TInput & A) const { - return static_cast(0.54 + 0.46 * std::cos(A * m_Factor)); + /** Equal to \f$ \frac{\pi}{m} \f$ */ + static constexpr double factor = Math::pi / VRadius; + return static_cast(0.54 + 0.46 * std::cos(A * factor)); } - -private: - /** Equal to \f$ \frac{\pi}{m} \f$ */ - static const double m_Factor; }; /** @@ -85,12 +82,10 @@ class ITK_TEMPLATE_EXPORT WelchWindowFunction inline TOutput operator()(const TInput & A) const { - return static_cast(1.0 - A * m_Factor * A); + /** Equal to \f$ \frac{1}{m^2} \f$ */ + static constexpr double factor = 1.0 / (VRadius * VRadius); + return static_cast(1.0 - A * factor * A); } - -private: - /** Equal to \f$ \frac{1}{m^2} \f$ */ - static const double m_Factor; }; /** @@ -112,14 +107,12 @@ class ITK_TEMPLATE_EXPORT LanczosWindowFunction if (A == 0.0) { return static_cast(1.0); - } - const double z = m_Factor * A; + } // namespace Function + /** Equal to \f$ \frac{\pi}{m} \f$ */ + static constexpr double factor = Math::pi / VRadius; + const double z = factor * A; return static_cast(std::sin(z) / z); - } - -private: - /** Equal to \f$ \frac{\pi}{m} \f$ */ - static const double m_Factor; + } // namespace itk }; /** @@ -136,17 +129,16 @@ class ITK_TEMPLATE_EXPORT BlackmanWindowFunction inline TOutput operator()(const TInput & A) const { - return static_cast(0.42 + 0.5 * std::cos(A * m_Factor1) + 0.08 * std::cos(A * m_Factor2)); - } + /** Equal to \f$ \frac{\pi}{m} \f$ */ + static constexpr double factor1 = Math::pi / VRadius; -private: - /** Equal to \f$ \frac{\pi}{m} \f$ */ - static const double m_Factor1; - - /** Equal to \f$ \frac{2 \pi}{m} \f$ */ - static const double m_Factor2; + /** Equal to \f$ \frac{2 \pi}{m} \f$ */ + static constexpr double factor2 = 2.0 * Math::pi / VRadius; + return static_cast(0.42 + 0.5 * std::cos(A * factor1) + 0.08 * std::cos(A * factor2)); + } }; } // namespace Function +// clang-format on /** * \class WindowedSincInterpolateImageFunction @@ -353,11 +345,10 @@ class ITK_TEMPLATE_EXPORT WindowedSincInterpolateImageFunction unsigned int m_WeightOffsetTable[m_OffsetTableSize][ImageDimension]{}; /** The sinc function */ - inline double - Sinc(double x) const + static double + Sinc(const double x) { - const double px = itk::Math::pi * x; - + const double px = Math::pi * x; return (x == 0.0) ? 1.0 : std::sin(px) / px; } }; diff --git a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx index fbf5460a377..b2e49d40eeb 100644 --- a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx @@ -23,29 +23,6 @@ namespace itk { - -// Constant definitions for functions -namespace Function -{ -template -const double CosineWindowFunction::m_Factor = itk::Math::pi / (2 * VRadius); - -template -const double HammingWindowFunction::m_Factor = itk::Math::pi / VRadius; - -template -const double WelchWindowFunction::m_Factor = 1.0 / (VRadius * VRadius); - -template -const double LanczosWindowFunction::m_Factor = itk::Math::pi / VRadius; - -template -const double BlackmanWindowFunction::m_Factor1 = itk::Math::pi / VRadius; - -template -const double BlackmanWindowFunction::m_Factor2 = 2.0 * itk::Math::pi / VRadius; -} // end namespace Function - template