3. Thin-plate spline module (symmetrize.tps)¶
-
symmetrize.tps.
tpsWarping
(from_points, to_points, images=None, axis=None, interpolation_order=1, approximate_grid=1, **kwds)[source]¶ Calculate the thin-plate spline (TPS) warping transform that from the from_points to the to_points, and then warp the given images by that transform. This transform is described in the paper: “Principal Warps: Thin-Plate Splines and the Decomposition of Deformations” by F.L. Bookstein.
Parameters: - from_points, to_points : 2D array, 2D array (dim = n x 2)
Correspondence point sets containing n 2D landmarks from the distorted and ideal images. The coordinates are in the (row, column) convention.
- images : 3D array | None
3D image stack to warp with the calculated thin-plate spline transform.
- axis : int | None
Image stacking axis in 3D image. Specify None to mean 2D image.
- interpolation_order : int | 1
If 1, then use linear interpolation; if 0 then use nearest-neighbor. See
scipy.ndimage.map_coordinates()
.- approximate_grid : int | 1
Use the approximate grid (if set > 1) for the transform. The approximate grid is smaller than the output image region, and then the transform is bilinearly interpolated to the larger region. This is fairly accurate for values up to 10 or so.
- kwds : keyword arguments
output_region: tuple | (0, 0, # of columns in image, # of rows in image) The (xmin, ymin, xmax, ymax) region of the output image that should be produced. (Note: The region is inclusive, i.e. xmin <= x <= xmax).
ret: str | ‘all’ Function return specification.
'image'
: return the transformed image.'deform'
: return the deformation field.'all'
: return both the transformed images and deformation field.
Returns: - images_tf : nD array
Transformed image stack.
- transform : list
Deformation field along x and y axes.