Skip to content

Commit

Permalink
Fixed two bugs with intensity display
Browse files Browse the repository at this point in the history
  • Loading branch information
pyushkevich committed Nov 22, 2024
1 parent 9010d0a commit 77bb03e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Logic/ImageWrapper/GuidedNativeImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,16 @@ class RescaleVectorNativeImageToVectorFunctor
RescaleVectorNativeImageToVectorFunctor()
: m_Shift(0), m_Scale(1) {}

template <typename U = TPixel, typename std::enable_if<std::is_integral<U>::value, int>::type = 0>
void operator()(TNative *src, TPixel *trg)
{
*trg = (TPixel) ((*src + m_Shift) * m_Scale + 0.5);
*trg = static_cast<TPixel>(std::round((*src + m_Shift) * m_Scale));
}

template <typename U = TPixel, typename std::enable_if<std::is_floating_point<U>::value, int>::type = 0>
void operator()(TNative *src, TPixel *trg)
{
*trg = static_cast<TPixel>((*src + m_Shift) * m_Scale);
}

protected:
Expand Down Expand Up @@ -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<OutputComponentType>::is_integer)
{
// We must compute the range of the input data
OutputComponentType omax = itk::NumericTraits<OutputComponentType>::max();
Expand Down
2 changes: 1 addition & 1 deletion Logic/ImageWrapper/ImageWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 77bb03e

Please sign in to comment.