我想逆转以下转换。以下是我在Python中使用SITK库进行的B样条转换:
def get_random_bspline_2d(physical,m=4):
dimension = 2
spline_order = 3
bspline = sitk.BSplineTransform(dimension, spline_order)
bspline.SetTransformDomainPhysicalDimensions(physical)
mesh_size = [m,m]
bspline.SetTransformDomainMeshSize(mesh_size)
# Random displacement of the control points.
originalControlPointDisplacements = np.random.random(len(bspline.GetParameters())) * 20 - 10
bspline.SetParameters(originalControlPointDisplacements)
return bspline
bspline = get_random_bspline_2d([100,100])
img = sitk.GetImageFromArray(np.reshape(np.arange(100*100),[100,100]))
img_transformed = sitk.GetArrayFromImage(sitk.Resample(img, bspline))
#plt.imshow(img_transformed)