Spatial transformers#
Modules which apply a spatial transformation to a given input data tensor.
A spatial transformer applies a SpatialTransform
, which takes as input point coordinates
and maps these to new spatial locations, to a given input data tensor.
Image transformer#
Spatially transform an image.
The ImageTransformer
applies a SpatialTransform
to the sampling grid
points of the target domain, optionally followed by linear transformation from target to
source domain, and samples the input image of shape (N, C, ..., X)
at these deformed
source grid points. If the spatial transformation is non-rigid, this is also commonly
referred to as warping the input image.
Note that the ImageTransformer.forward()
method invokes the spatial transform as
functor, i.e., it triggers any pre-forward and post-forward hooks that are registered with
the spatial transform when evaluating it. This in particular includes the forward pre-hook
that invokes SpatialTransform.update()
(cf. SpatialTransformer
).
Point set transformer#
Spatially transform a set of points.
The PointSetTransformer
applies a SpatialTransform
to a set of input points
with coordinates defined with respect to a specified target domain. This coordinate map may
further be followed by a linear transformation from the grid domain of the spatial transform
to a given source domain. When no spatial transform is given, use grid_transform_points()
.
The forward method of a point set transformer performs the same operation as SpatialTransform.points()
,
but with the target and source domain arguments specified during transformer initialization. In addition,
the point set transformer module invokes the spatial transform as a functor such that any registered
forward pre- and post-hooks are executed as part of the spatial transform evaluation. This includes the
forward pre-hook that invokes SpatialTransform.update()
(cf. SpatialTransformer
).