Shortcuts

rising.utils

Affines

rising.utils.affine.deg_to_rad(angles)[source][source]

Converts from degree to radians.

Parameters

angles (Union[Tensor, float, int]) – the (vectorized) angles to convert

Returns

the transformed (vectorized) angles

Return type

torch.Tensor

rising.utils.affine.get_batched_eye(batchsize, ndim, device=None, dtype=None)[source][source]

Produces a batched matrix containing 1s on the diagonal

Parameters
  • batchsize (int) – int the batchsize (first dimension)

  • ndim (int) – int the dimensionality of the eyes (second and third dimension)

  • device (Union[device, str, None]) – torch.device, str, optional the device to put the resulting tensor to. Defaults to the default device

  • dtype (Union[dtype, str, None]) – torch.dtype, str, optional the dtype of the resulting trensor. Defaults to the default dtype

Returns

batched eye matrix

Return type

torch.Tensor

rising.utils.affine.matrix_revert_coordinate_order(batch)[source][source]

Reverts the coordinate order of a matrix (e.g. from xyz to zyx).

Parameters

batch (Tensor) – the batched transformation matrices; Should be of shape BATCHSIZE x NDIM x NDIM

Returns

the matrix performing the same transformation on vectors with a

reversed coordinate order

Return type

torch.Tensor

rising.utils.affine.matrix_to_cartesian(batch, keep_square=False)[source][source]

Transforms a matrix for a homogeneous transformation back to cartesian coordinates.

Parameters
  • batch (Tensor) – the batch oif matrices to convert back

  • keep_square (bool) – if False: returns a NDIM x NDIM+1 matrix to keep the translation part if True: returns a NDIM x NDIM matrix but looses the translation part. defaults to False.

Returns

the given matrix in cartesian coordinates

Return type

torch.Tensor

rising.utils.affine.matrix_to_homogeneous(batch)[source][source]

Transforms a given transformation matrix to a homogeneous transformation matrix.

Parameters

batch (Tensor) – the batch of matrices to convert [N, dim, dim]

Returns

the converted batch of matrices

Return type

torch.Tensor

rising.utils.affine.points_to_cartesian(batch)[source][source]

Transforms a batch of points in homogeneous coordinates back to cartesian coordinates.

Parameters

batch (Tensor) – batch of points in homogeneous coordinates. Should be of shape BATCHSIZE x NUMPOINTS x NDIM+1

Returns

the batch of points in cartesian coordinates

Return type

torch.Tensor

rising.utils.affine.points_to_homogeneous(batch)[source][source]

Transforms points from cartesian to homogeneous coordinates

Parameters

batch (Tensor) – the batch of points to transform. Should be of shape BATCHSIZE x NUMPOINTS x DIM.

Returns

the batch of points in homogeneous coordinates

Return type

torch.Tensor

rising.utils.affine.unit_box(n, scale=None)[source][source]

Create a (scaled) version of a unit box

Parameters
  • n (int) – number of dimensions

  • scale (Optional[Tensor]) – scaling of each dimension

Returns

scaled unit box

Return type

torch.Tensor

points_to_homogeneous

rising.utils.affine.points_to_homogeneous(batch)[source][source]

Transforms points from cartesian to homogeneous coordinates

Parameters

batch (Tensor) – the batch of points to transform. Should be of shape BATCHSIZE x NUMPOINTS x DIM.

Returns

the batch of points in homogeneous coordinates

Return type

torch.Tensor

matrix_to_homogeneous

rising.utils.affine.matrix_to_homogeneous(batch)[source][source]

Transforms a given transformation matrix to a homogeneous transformation matrix.

Parameters

batch (Tensor) – the batch of matrices to convert [N, dim, dim]

Returns

the converted batch of matrices

Return type

torch.Tensor

matrix_to_cartesian

rising.utils.affine.matrix_to_cartesian(batch, keep_square=False)[source][source]

Transforms a matrix for a homogeneous transformation back to cartesian coordinates.

Parameters
  • batch (Tensor) – the batch oif matrices to convert back

  • keep_square (bool) – if False: returns a NDIM x NDIM+1 matrix to keep the translation part if True: returns a NDIM x NDIM matrix but looses the translation part. defaults to False.

Returns

the given matrix in cartesian coordinates

Return type

torch.Tensor

points_to_cartesian

rising.utils.affine.points_to_cartesian(batch)[source][source]

Transforms a batch of points in homogeneous coordinates back to cartesian coordinates.

Parameters

batch (Tensor) – batch of points in homogeneous coordinates. Should be of shape BATCHSIZE x NUMPOINTS x NDIM+1

Returns

the batch of points in cartesian coordinates

Return type

torch.Tensor

matrix_revert_coordinate_order

rising.utils.affine.matrix_revert_coordinate_order(batch)[source][source]

Reverts the coordinate order of a matrix (e.g. from xyz to zyx).

Parameters

batch (Tensor) – the batched transformation matrices; Should be of shape BATCHSIZE x NDIM x NDIM

Returns

the matrix performing the same transformation on vectors with a

reversed coordinate order

Return type

torch.Tensor

get_batched_eye

rising.utils.affine.get_batched_eye(batchsize, ndim, device=None, dtype=None)[source][source]

Produces a batched matrix containing 1s on the diagonal

Parameters
  • batchsize (int) – int the batchsize (first dimension)

  • ndim (int) – int the dimensionality of the eyes (second and third dimension)

  • device (Union[device, str, None]) – torch.device, str, optional the device to put the resulting tensor to. Defaults to the default device

  • dtype (Union[dtype, str, None]) – torch.dtype, str, optional the dtype of the resulting trensor. Defaults to the default dtype

Returns

batched eye matrix

Return type

torch.Tensor

deg_to_rad

rising.utils.affine.deg_to_rad(angles)[source][source]

Converts from degree to radians.

Parameters

angles (Union[Tensor, float, int]) – the (vectorized) angles to convert

Returns

the transformed (vectorized) angles

Return type

torch.Tensor

unit_box

rising.utils.affine.unit_box(n, scale=None)[source][source]

Create a (scaled) version of a unit box

Parameters
  • n (int) – number of dimensions

  • scale (Optional[Tensor]) – scaling of each dimension

Returns

scaled unit box

Return type

torch.Tensor

Type Checks

rising.utils.checktype.check_scalar(x)[source][source]

Provide interface to check for scalars

Parameters

x (Union[Any, float, int]) – object to check for scalar

Return type

bool

Returns

bool” True if input is scalar

check_scalar

rising.utils.checktype.check_scalar(x)[source][source]

Provide interface to check for scalars

Parameters

x (Union[Any, float, int]) – object to check for scalar

Return type

bool

Returns

bool” True if input is scalar

Reshaping

rising.utils.shape.reshape(value, size)[source][source]

Reshape sequence (list or tensor) to given size

Parameters
Returns

reshaped sequence

Return type

Union[torch.Tensor, list]

rising.utils.shape.reshape_list(flat_list, size)[source][source]

Reshape a (nested) list to a given shape

Parameters
  • flat_list (list) – (nested) list to reshape

  • size (Union[Size, tuple]) – shape to reshape to

Returns

reshape list

Return type

list

reshape

rising.utils.shape.reshape(value, size)[source][source]

Reshape sequence (list or tensor) to given size

Parameters
Returns

reshaped sequence

Return type

Union[torch.Tensor, list]

reshape_list

rising.utils.shape.reshape_list(flat_list, size)[source][source]

Reshape a (nested) list to a given shape

Parameters
  • flat_list (list) – (nested) list to reshape

  • size (Union[Size, tuple]) – shape to reshape to

Returns

reshape list

Return type

list


© Copyright Copyright (c) 2019-2020, Justus Schock, Michael Baumgartner.. Revision 437f8919.

Read the Docs v: v0.2.2
Versions
latest
stable
v0.2.2
v0.2.1
v0.2.0post0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.