interpolate stack of images

I have a stack of images where the thickness of each slice is known and there is a gap of known distance between each slice.
I have used and seen where image resampling is used to create isotropic volumes from image slices that are thicker but don’t have a gap between it and the next slice.

Does anyone have a suggestion of alternative to the resampling or does resampling solve the same problem whether there is a known gap or not?

Actually, this is a very simple task. You can create a grid transform that maps 4 corners of each slice in IJK coordinate system to the 4 corners in LPS coordinate system, then resample the image using this transform. This is implemented in AcquisitionModeling class in 3D Slicer’s DICOM importer to create a regular Cartesian volume from variable-spacing and/or tilted-gantry acquisitions.

For more general 3D image reconstruction from thick, intersecting, and/or overlapping slices or subvolumes, you need a bit more complex methods. For example, you can use Plus toolkit, which is developed for freehand 3D ultrasound reconstruction.


It looks like grid transform is a VTK thing and not an ITK thing, so would I need to make my own itk like transform or some kind of bridge functionality?

“Grid” transform in VTK is the same as “displacement field” transform in ITK.

Thank you. I attempted to modify the class to use sitk. Getting the displacement grid makes sense, but how to use it properly with displacement field transform is confusing and can’t find a decent example . I will post some code tomorrow.

Hello @kayarre,

Example code for resampling with SimpleITK can be found in this Jupyter notebook, As a DisplacementFieldTransform is just a SimpleITK transform the resampling functions will all accept it.

Thank you @zivy, I will try that. maybe I don’t understand how to get the displacement field mapped correctly. I have a [2,2,slices] vectorfloat64 with 3 components per pixel. if the input ijk image has the regular direction [1 0 0 0 1 0 0 0 1], Only a displacement field that is [0 0 z] is required for each image? Does it need to generate a dense deformation field from that? is 4 corners all one needs?

when I resample, should the references image be representative in size and type of the correct spacing I want for the output?

I was able to build an image volume with the proper spacing but has blank slices in the gaps as opposed to interpolated images in between.

I will give it another whirl, thank you so much @lassoan as well.

The thing about the slicer example is that its using the Slicer api, and registers the transform so it updates things once the filter is called, I think.

[2,2,slices] displacement vectors are all you need. ITK interpolates between these vectors automatically.


Make sure position vectors in your [2,2,slices] vector volume corresponds to corners of your image slices. Use the inverse of this transform to resample your image volume.

Is there any particular issue that prevents you from using this feature in Slicer?