I have a 3D image in raw format, the
.mhd file is similar to this one:
ObjectType = Image NDims = 3 ElementSpacing = 0.031473 0.031473 0.031473 DimSize = 100 100 100 ElementType = MET_SHORT ElementDataFile = phantom.raw
I would like to get an interpolated value at non-integer voxel coordinate.
With this program I can get the value for example at coordinate 25,50,50:
import SimpleITK as sitk import numpy as np # Reads the image using SimpleITK itkimage = sitk.ReadImage('phantom.mhd') # Convert the image to a numpy array first and then shuffle the dimensions to get axis in the order z,y,x ct_scan = sitk.GetArrayFromImage(itkimage) print(ct_scan[25,50,50])
But what if I need the value say at
I think I need to use a
ResampleImageFilter and I would like to use the interpolator of type
WindowedSincInterpolateImageFunction but I am not capable to adapt the examples I have found (i.e.
https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/Filtering/ResampleImageFilter8.cxx) because they seem to be always related to a transformation like a rotation or a translation of the whole image.
My final goal is to get not just one interpolated value but N values for example along a curve.