Page MenuHomePhabricator

mitk::Image::GetPixelValueByIndex missing a check
Closed, ResolvedPublic

Description

In mitk::Image::GetPixelValueByIndex(const mitk::Index3D &position, unsigned int timestep)

There are some checks missing:

1st:
the current code:
"

if (this->GetTimeSteps() < timestep)
{
  timestep = this->GetTimeSteps();
}

"
is wrong. It should be
"

if (this->GetTimeSteps() < timestep)
{
  timestep = this->GetTimeSteps() - 1;
}

"

But actually it would be much better do give an exception!

The current check for the position, if it is not inside the image, is also just giving a warning and returns the pixelvalue 0.
It should actually give an exception.

Event Timeline

GetPixelValueByIndex is deprecated. This problem is solved with mitk::ImagePixelReadAccessor::GetPixelByIndexSafe.