[Insight-users] itk::ResampleImageFilter bug
Simon Warfield
simon.warfield at childrens.harvard.edu
Sun Aug 10 15:53:56 EDT 2008
insight-users-request at itk.org wrote:
> Date: Sun, 10 Aug 2008 22:16:58 +0800
> From: "Jun Xiong" <junxiongcn at gmail.com>
> Subject: [Insight-users] A problem of image border when using
> itk::ResampleImageFilter!
> To: insight-users at itk.org
> Message-ID:
> <5a5a6dd00808100716j47d49346ic075afa087f4e145 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Dear all,
>
> I have a question about the image border interpolation question
> when using ResampleImageFilter. If i use itk::ResampleImageFilter to
> resample an image to a bigger size, the area around the image border
> (about half of the Spacing value), are NOT interpolated and as a
> result the borders are fade to the default pixel value of the
> resampling filter. For example, if i resample a slice(256*256) from
> the volume(size:128*128*64) in the x-z orientation(using the same
> spacing), the result image only contains 126 line effective data in
> the middle, others are default value. It seems that, the outer half
> of the image border are not interpolated and their values were set as
> the default value directly.
> If i use the PadImageFilter to pad the volume with one pixel, the
> result image contains 130 lines effective data. How can i get a result
> image containing 128 lines.
> Thank you very much!
>
I think some of the interpolators and some of the image classes don't
implement the definition of the coordinate system correctly.
http://www.vtk.org/Bug/view.php?id=6558
You might try the nearest neighbour interpolator, because that is
reported to work correctly.
I guess you are using the linear interpolator.
If you want to dig into it some more,
EvaluateAtContinuousIndex on line 77 of
itkLinearInterpolateImageFunction.txx
implements the linear interpolation.
You can check the implementation to see if it is correctly evaluating
the distances to neighboring voxels. It goes to tremendous trouble to
avoid using a vcl_floor(),
but it is mainly called by itkResampleImageFilter (line 285), which does
a vcl_floor() on the indexes in a loop over every dimension immediately
beforehand (line 276).
This result is subjected to an obscure adjustment to correct for errors
in the calculations that have lead to this point (lines 262-279) and it
wouldn't surprise me if this was
causing your problems.
It might also be that the check for being inside the buffer on line 281
is actually returning a boolean that is inconsistent with the weight
calculation in the linear interpolator.
The IsInsideBuffer() calculation ultimately calls itkImageFunction.txx
line 145 (since it is being passed a ContinuousIndex), which does not
call vcl_floor() to find the correct
index to evaluate.
Dan had some success correcting the interpolation by modifying this for
some of the interpolators to overload the IsInsideBuffer calculation to
return the correct result.
http://www.itk.org/mailman/private/insight-developers/2008-June/010427.html
There was a report of a bug fix here:
http://www.itk.org/pipermail/insight-users/2006-December/020434.html
http://www.itk.org/pipermail/insight-users/2006-December/020469.html
and an open bug about the issue here:
http://www.paraview.org/Bug/view.php?id=738
--
Simon
More information about the Insight-users
mailing list