[Insight-developers] Bug in ImageFunction causing incorrect results from ResampleImageFilter

Karthik Krishnan karthik.krishnan at kitware.com
Mon Jun 2 12:57:10 EDT 2008


Dan:

I ran into this a long time ago, when dealing with thick slice MR
data, the last slice of which was being resampled with blank data.

Please see the following bug report and fix (which I backed out a day
later) I had posted a long time ago:

  http://www.itk.org/Bug/view.php?id=3647

Please also see its discussion on the mailing list:

  http://www.itk.org/pipermail/insight-users/2006-December/020434.html
  http://www.itk.org/mailman/private/insight-developers/2006-August/008340.html

The following commits (backed out in the next CVS commit :), see
discussion above again for details) address this.


ImageFunction.txx
----------------------------
revision 1.40
date: 2006-08-22 00:00:22 +0000;  author: karthik;  state: Exp;  lines: +7 -6;
BUG: Fix bug 3647


itkLinearInterplateImageFunction.txx
----------------------------
revision 1.34
date: 2006-08-22 00:00:22 +0000;  author: karthik;  state: Exp;  lines: +7 -3;
BUG: Fix bug 3647
----------------------------



This is really an offshoot of the same discussion about the exact
interpretation of itk::Index.

  "Do we fix its location of the index at the corner of the voxel or
at the center ?"

The current convention is to fix it at the corner.

With this change (and the one earlier committed), we are really trying
to change the interpretation of Index keeping this new interpretation
localized to the interpolator alone.

Arguably, the fix solution might be fine, since the interpolator is
responsible for deciding what the sampling function should be and
where it should sample voxels. It can also be argued that its not,
stating that fixing the interpolator would imply fixing it
elsewhere... :)

Thanks
-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.


On Mon, Jun 2, 2008 at 4:10 PM, Blezek, Daniel J., Ph.D.
<Blezek.Daniel at mayo.edu> wrote:
> I have some fairly thick CT slices (5mm) that I would like to resample
> to be isotropic.  A straightforward use of ResampleImageFilter leaves 4
> blank slices in the output volume.  I've tracked this down to a bug(?)
> in ImageFunction.  This code is incorrect IMHO:
>
>  virtual bool IsInsideBuffer( const ContinuousIndexType & index ) const
>    {
>      for ( unsigned int j = 0; j < ImageDimension; j++ )
>        {
>        if ( index[j] < m_StartContinuousIndex[j] ) { return false; };
>        if ( index[j] > m_EndContinuousIndex[j] ) { return false; };
>        }
>      return true;
>    }
>
> (Dealing with Z in 3D) This code assumes the last slice has zero
> thickness.  For N slices, the range where IsInsideBuffer returns true is
> [0, N-1).  This is incorrect, the correct result should be [0, N).  [0,
> N) gives the last slice it's proper thickness.  The windowed Sinc
> interpolator properly handles the last slice, i.e. [N-1, N), but I have
> not checked others.  A proper implementation would look like this (note
> the vcl_floor calls):
>
>          if ( vcl_floor(index[j]) < m_StartContinuousIndex[j] ) {
> return false; };
>          if ( vcl_floor(index[j]) > m_EndContinuousIndex[j] ) { return
> false; };
>
>
> I've run all the tests on a fresh check out with the above change.  As
> may be expected, almost all of the registration tests fail, while most
> of the resample tests pass.  Surprisingly,
> ResampleVolumesToBeIsotropicTest passed...
>
> Any comments on this bug?  Should the tests be made to accommodate the
> change, or should I override the method in a custom interpolator?
>
> Regards,
> -dan
>
>
>
> Daniel Blezek, PhD
> Medical Imaging Informatics Innovation Center
> Enterprise Imaging Systems Unit
>
> P 127 or (77) 8 8886
> T 507 538 8886
> E blezek.daniel at mayo.edu
>
> Mayo Clinic
> 200 First St. S.W.
> Harwick SL-44
> Rochester, MN 55905
> mayoclinic.org
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list