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

Blezek, Daniel J., Ph.D. Blezek.Daniel at mayo.edu
Mon Jun 2 13:24:14 EDT 2008


Hi Karthik,

  Shows that I need to read the mailing list more carefully.  I think
the fault lies both in ImageFunction and the Interpolators.  The
interpolaters should properly view slices as having thickness, not just
as point samples.
 
  Perhaps if enough people bump into this, we can generate some more
discussion.

  The good news is that simply subclassing the interpolator and
overriding IsInsideBuffer makes it work for me.

Regards,
-dan 

-----Original Message-----
From: Karthik Krishnan [mailto:karthik.krishnan at kitware.com] 
Sent: Monday, June 02, 2008 11:57 AM
To: Blezek, Daniel J., Ph.D.
Cc: insight-developers at itk.org
Subject: Re: [Insight-developers] Bug in ImageFunction causing incorrect
results from ResampleImageFilter

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