[Insight-users] TransformPhysicalPointToIndex-method in Image class

Hämäläinen Janne Janne.Hamalainen at hus.fi
Tue, 30 Mar 2004 14:08:22 +0300


Hi,

I suspect that this question has been debated before, but I wasn't able find
anything about it from the archives. 

We use the TransformPhysicalPointToIndex-method of itk::Image-class to get
the index of single voxel inside an image object. The index is exploited for
tracing the scalar value of a single pixel. However, the transforming
function doesn't seem to behave as we thought it would, so we kindly ask
your assistance for how to interpret the behavior. First of all, the ITK
Software Guide specifies (in p. 40) that the coverage of a voxel is the
Voronoi region around the physical position of the voxel. In our
implementation we noticed anyhow that the behavior of the
TransformPhysicalPointToIndex-method seems a bit different. Here is a clip
from the method:

/****** From itk::Image-class (itkImage.h, lines 314-318) ***********/

    // Update the output index
    for (unsigned int i = 0 ; i < VImageDimension ; i++)
      {
      index[i] = static_cast<IndexValueType>( (point[i]- m_Origin[i]) /
m_Spacing[i] );
      }

/***************************************************************************
/

In short, you first calculate the continouos index
((point[i]-m_Origin[i]/m_Spacing[i]) from the physical point, and then cast
the acquired floating point value to an integer value (value type of the
index is a long integer according to the Index-class). But in our
understanding this causes half a voxel shift compared to the Voronoi region
interpretation, because the cast operation just truncates the floating point
value, instead of rounding it. We think that rounding of the continuous
index before the cast would give the index according to the Voronoi region
interpretation. Is this a bug, or is it the intended behavior?

-Janne