AlbumentationsExplore
DocumentationExploreAdoptionPricingBlog
GitHub

RandomRotate90_3D

Targets:
volume
mask3d
keypoints
Image Types:uint8, float32

Rotate a volume by a random 90-degree multiple across one spatial axis pair, rotating mask3d and XYZ keypoints without reflections.

Quarter turns swap the selected depth, height, or width lengths while preserving the channel axis.

Axis indices always use (depth, height, width) order: (0, 1) rotates depth with height, (0, 2) rotates depth with width, and (1, 2) rotates height with width. A 90-degree or 270-degree turn swaps the two selected lengths, so non-cubic input can change shape. A 180-degree turn and the identity preserve the original shape. The transform does not reflect data.

Set both axis_pair and group_element for deterministic test-time augmentation. inverse() then returns the rotation that restores the original voxel and keypoint coordinates.

Arguments
axis_pairs
tuple[tuple[[0, 1, 2], [0, 1, 2]], ...]
[, , ]

Non-empty set of axis pairs sampled in random mode. Each pair must list two distinct axes in ascending (depth, height, width) order. Default: ((0, 1), (0, 2), (1, 2)).

axis_pair
tuple[[0, 1, 2], [0, 1, 2]] | None

Fixed spatial axis pair. Set with group_element for deterministic TTA. Default: None.

group_element
e | r90 | r180 | r270 |

If set, always apply this C4 group element: "e"=identity, "r90"=90°, "r180"=180°, "r270"=270° counterclockwise. Use for TTA. Default: None (random choice).

p
float
1

Probability of applying the transform. Default: 1.0.

Examples
>>> import numpy as np
>>> import albumentations as A
>>> volume = np.arange(2 * 3 * 5, dtype=np.uint8).reshape(2, 3, 5, 1)
>>> transform = A.RandomRotate90_3D(axis_pair=(0, 2), group_element="r90", p=1.0)
>>> result = transform(volume=volume)
>>> result["volume"].shape
(5, 3, 2, 1)
See Also
  • Affine3D: Sample continuous rotations with interpolation and optional scale or translation.