xnn.cnn.models.base.rotate_voxels#

xnn.cnn.models.base.rotate_voxels(x, R)[source]#

Rotate scalar voxel grids by a symmetry of the cube, exactly.

Returns the grids of f(R^{-1} x) for R one of the 48 signed permutation matrices (the rotations and reflections mapping the cubic grid onto itself), which needs no interpolation. The fiber (channel) transformation of non-scalar fields is the caller’s job.

Parameters:
  • x (Tensor) – Grids of shape (..., s, s, s).

  • R (Tensor) – A (3, 3) signed permutation matrix.

Returns:

The rotated grids, same shape as x.

Return type:

Tensor

Raises:

ValueError – If R is not a signed permutation matrix.