Page MenuHomePhabricator

Strange function in mitk::Geometry3D()
Closed, ResolvedPublic

Description

This function is quite likely not respecting center-based World coordinates.

//##Documentation

//## @brief Convert world coordinates (in mm) of a \em point to index coordinates (in units).
//## This method rounds to integer indices!
template <unsigned int VIndexDimension>
   void WorldToIndex(const mitk::Point3D &pt_mm, itk::Index<VIndexDimension> &index) const
{
  typedef itk::Index<VIndexDimension> IndexType;
  mitk::Point3D pt_units;
  WorldToIndex(pt_mm, pt_units);
  int i, dim=index.GetIndexDimension();
  if(dim>3)
  {
    index.Fill(0);
    dim=3;
  }
  for(i=0;i<dim;++i){
    if(pt_units[i]<0)
      pt_units[i]-=0.5;
    else
      pt_units[i]+=0.5;
    index[i]=(typename IndexType::IndexValueType)pt_units[i];
  }
}

Event Timeline

Looking at mitk::Geometry3D, there are still some remnants from before voxel center change, as well as not adapted mehtods (not noticed because they are not used). This class has to be cleaned up for the new coordinate system.

It seems that in this function the 0.5 pixel offset is calculated a second time (but wrong for negative values(?) ).

Not the pixel offset is changed, but rounded.
Anyhow, the rounding is not compatible with the changed coordinate systems anymore.
Must use floor().

[SVN revision 20007]
FIX (#2401): Adapt convenience method for WorldToIndex with Itk Index to
corrected MITK coordinate system, and therefore rounding.

Sorry, accidentally committed to wrong bug Id.