From 77bb03e7e9e00d0665ba3da4ddc06cfa9f033a00 Mon Sep 17 00:00:00 2001 From: Paul Yushkevich Date: Fri, 22 Nov 2024 10:17:49 -0500 Subject: [PATCH] Fixed two bugs with intensity display --- Logic/ImageWrapper/GuidedNativeImageIO.cxx | 12 ++++++++++-- Logic/ImageWrapper/ImageWrapper.cxx | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Logic/ImageWrapper/GuidedNativeImageIO.cxx b/Logic/ImageWrapper/GuidedNativeImageIO.cxx index 045535df..0c8b9a34 100755 --- a/Logic/ImageWrapper/GuidedNativeImageIO.cxx +++ b/Logic/ImageWrapper/GuidedNativeImageIO.cxx @@ -1663,9 +1663,16 @@ class RescaleVectorNativeImageToVectorFunctor RescaleVectorNativeImageToVectorFunctor() : m_Shift(0), m_Scale(1) {} + template ::value, int>::type = 0> void operator()(TNative *src, TPixel *trg) { - *trg = (TPixel) ((*src + m_Shift) * m_Scale + 0.5); + *trg = static_cast(std::round((*src + m_Shift) * m_Scale)); + } + + template ::value, int>::type = 0> + void operator()(TNative *src, TPixel *trg) + { + *trg = static_cast((*src + m_Shift) * m_Scale); } protected: @@ -1701,7 +1708,8 @@ ::DoCast(NativeImageType *native) typedef typename OutputImageType::InternalPixelType OutputComponentType; // Only bother with computing the scale and shift if the types are different - if(typeid(OutputComponentType) != typeid(TNative)) + // and if the output type is not floating point + if(typeid(OutputComponentType) != typeid(TNative) && itk::NumericTraits::is_integer) { // We must compute the range of the input data OutputComponentType omax = itk::NumericTraits::max(); diff --git a/Logic/ImageWrapper/ImageWrapper.cxx b/Logic/ImageWrapper/ImageWrapper.cxx index df806f1c..30fe58a6 100644 --- a/Logic/ImageWrapper/ImageWrapper.cxx +++ b/Logic/ImageWrapper/ImageWrapper.cxx @@ -1852,7 +1852,7 @@ ::SampleIntensityAtReferenceIndexInternal( InterpolateWorker iw(m_ImageTimePoints[tp]); // Process the voxel, arr will be updated by the function - iw.ProcessVoxel(cidx.GetDataPointer(), false, &arr); + iw.ProcessVoxel(cidx.GetDataPointer(), true, &arr); } } }