PytorchBackend.rigid_transform#

PytorchBackend.rigid_transform(arr, rotation_matrix, arr_mask=None, translation=None, use_geometric_center=False, out=None, out_mask=None, order=1, cache=False)[source]#

Rotates the given tensor arr based on the provided rotation_matrix.

This function optionally allows for rotating an accompanying mask tensor (arr_mask) alongside the main tensor. The rotation is defined by the rotation_matrix and the optional translation.

Parameters:
arrTorchTensor

The input tensor to be rotated.

rotation_matrixTorchTensor

The rotation matrix to apply. Must be square and of shape [d x d].

arr_maskTorchTensor, optional

The mask of arr to be equivalently rotated.

translationTorchTensor, optional

The translation to apply after rotation. Shape should match tensor dimensions [d].

outTorchTensor, optional

The output tensor to hold the rotated arr. If not provided, a new tensor will be created.

out_maskTorchTensor, optional

The output tensor to hold the rotated arr_mask. If not provided and arr_mask is given, a new tensor will be created.

orderint, optional

Spline interpolation order. Supports orders:

0

Use ‘nearest’ neighbor interpolation.

1

Use ‘bilinear’ interpolation for smoother results.

3

Use ‘bicubic’ interpolation for higher order smoothness.

Returns:
out, out_maskTorchTensor or Tuple[TorchTensor, TorchTensor] or None

Returns the rotated tensor(s). If out and out_mask are provided, the function will return None. If only arr is provided without out, it returns rotated arr. If both arr and arr_mask are given without out and out_mask, it returns a tuple of rotated tensors.

Notes

Only a region of the size of arr and arr_mask is considered for interpolation in out and out_mask respectively.

Currently bicubic interpolation is not supported for 3D inputs.