I noticed that when resampling an image using sitkBSpline, the background would not always be zero.
Here is an example:
import SimpleITK as sitk
import numpy as np
x = np.zeros((20,20))
x[5:15,5:15] = 1
img = sitk.GetImageFromArray(x)
tx = sitk.Euler2DTransform()
tx.SetAngle(np.deg2rad(30))
out = sitk.Resample(img, tx, sitk.sitkBSpline)
out2 = sitk.Resample(img, tx, sitk.sitkBSplineResampler)
plt.imshow(sitk.GetArrayFromImage(out)); plt.show()
plt.imshow(sitk.GetArrayFromImage(out2)); plt.show()
Interestingly, using sitkBSpline creates values less than 0 and greater than 1, which is not the case for sitkBSplineResampler.
The documentation says that the latter interpolator should only be used for āa BSpline coefficient imageā, however for me it looks like that it produces the better results? Especially as I would not suspect that the resampler introduces higher or lower values which were in the image before.
Is it save to use the sitkBSplineResampler as a default resampler instead of sitkBSpline, or is there any caveat Iām not aware of?
Iām using
SimpleITK Version: 2.0.0rc1.post287
Build Date: Jun 19 2020 02:53:28
ITK Version: 5.1
I think these are just variants of the same interpolation. You can probably use the sitkBSplineResampler.
Also, I suggest you set the default pixel value to something other than zero, you want to differentiate between pixels coming from interpolation and those from outside the image bounds:
The regular sitkBSpline interpolates the image with constructed coefficients to represent the intensities. While the sitkBSplineResampler using the image as coefficients to interpolate the results.
I would recommend only using sitkBSplineResampler to resample coefficient images as per the documentaiton.
Thank you for the answer!
Iām not sure if I understand ācoefficient imageā correctly, as I never heard that term before and can not make sense from it by looking at literatureā¦ Could you hint me to some literature explaining that or is there a synonym for it?
The main point is that there is a distinction between the signal intensities estimated from the coefficients of the b-spline representation of an image, and the coefficients of the b-spline representation of an image.