[vtkusers] [vtk-developers] About vtkImageReslice interpolation
David Gobbi
david.gobbi at gmail.com
Tue Jul 8 08:08:46 EDT 2014
Hi Simon,
If you are downsampling the image by simply changing the output
spacing, without introducing a shift in the positions of the samples,
then downsampling is a decimation operation (i.e. downsampling
by a factor of three is the same as taking every 3rd voxel). This is
true whether you use linear, cubic, or NN interpolation. The code
optimizes such decimations by turning off the interpolation.
In VTK, the Origin is at the center of the first voxel, so a straightforward
downsampling places centers each output voxel at exactly the position
of one of the input voxels, which is why downsampling becomes
decimation. To avoid this, you must shift the output Origin relative to
the input Origin.
The new vtkImageResize filter has BorderOn()/BorderOff() methods
to control this behavior. If Border is Off (the default) the behavior is
like vtkImageReslice. If Border in On, then the output origin is
automatically shifted relative to the input origin so that the shrink
factors are applied relative to the outer corner of the first voxel,
rather than relative to the center of the first voxel.
I'm not sure if that was a clear explanation, so let me know if you
still have questions.
- David
On Tue, Jul 8, 2014 at 3:41 AM, Simon ESNEAULT <simon.esneault at gmail.com> wrote:
> Hi All,
>
> We use vtkImageResample/vtkImageReslice (from vtk 5.8.1) quite a lot here,
> and I've noticed a strange behavior.
>
> If we down sample a volume by a factor of 2 in all 3 directions, the output
> image will be the exact same if we use a nearest neighborhood, linear or
> cubic interpolation. There seems to be no interpolation at all if the
> reduction factor is a power of two.
> If the reduction factor is set to 2.00001, the interpolation is performed
> correctly when asked for linear or cubic.
>
> Is this an intended behavior ?
>
> After some debugging :
> In the file vtkImageReslice.cxx, method vtkTricubicInterpCoeffs (line 1503)
> with a power of 2 factor we always fall back to the part with the comment //
> no interpolation (line 1510), but I don't understand why.
>
> And last question : there is a new vtkImageResize that was introduced in vtk
> 5.10, will the behavior be the same ?
>
> Thanks for your help
>
> -Simon
More information about the vtkusers
mailing list