Skip to content

Commit

Permalink
BUG: Replace Math::Round template argument double with int64_t
Browse files Browse the repository at this point in the history
According to https://github.com/InsightSoftwareConsortium/ITK/blob/66ab5b14c476d057ed46a4daba05b710681160e6/Modules/Core/Common/include/itkMath.h#L127
the `TReturn` template argument of `Math::Round` must be an integer type. In
practice, it will internally call `Detail::RoundHalfIntegerToEven_64` when
`TReturn` is a 64-bit `double`. Which returns an `int64_t` anyway.
  • Loading branch information
N-Dekker committed Jan 25, 2024
1 parent 902d1f2 commit 705f84f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "itkImageFileWriter.h"
#include "itkGaussianOperator.h"
#include "itkImageAlgorithm.h"
#include "itkIntTypes.h"
#include "itkVectorImageToImageAdaptor.h"
#include "itkSpatialNeighborSubsampler.h"
#include "itkMacro.h"
Expand All @@ -43,7 +44,7 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::PatchBasedDenoisingIm
m_MinProbability(NumericTraits<RealValueType>::min() * 100)
, // to avoid divide by zero
m_SigmaUpdateDecimationFactor(
static_cast<unsigned int>(Math::Round<double>(1.0 / m_KernelBandwidthFractionPixelsForEstimation)))
static_cast<unsigned int>(Math::Round<int64_t>(1.0 / m_KernelBandwidthFractionPixelsForEstimation)))
, m_NoiseSigma()
, m_NoiseSigmaSquared()
, m_SearchSpaceList(ListAdaptorType::New())
Expand Down Expand Up @@ -239,10 +240,10 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::Initialize()

// For automatic sigma estimation, select every 'k'th pixel.
m_SigmaUpdateDecimationFactor =
static_cast<unsigned int>(Math::Round<double>(1.0 / m_KernelBandwidthFractionPixelsForEstimation));
static_cast<unsigned int>(Math::Round<int64_t>(1.0 / m_KernelBandwidthFractionPixelsForEstimation));
// For automatic sigma estimation, use at least 1% of pixels.
m_SigmaUpdateDecimationFactor = std::min(m_SigmaUpdateDecimationFactor,
static_cast<unsigned int>(Math::Round<double>(m_TotalNumberPixels / 100.0)));
m_SigmaUpdateDecimationFactor = std::min(
m_SigmaUpdateDecimationFactor, static_cast<unsigned int>(Math::Round<int64_t>(m_TotalNumberPixels / 100.0)));
// For automatic sigma estimation, can't use more than 100% of pixels.
m_SigmaUpdateDecimationFactor = std::max(m_SigmaUpdateDecimationFactor, 1u);

Expand Down

0 comments on commit 705f84f

Please sign in to comment.