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.
axis_pairsNon-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_pairFixed spatial axis pair. Set with group_element for
deterministic TTA. Default: None.
group_elementIf set, always apply this C4 group element:
"e"=identity, "r90"=90°, "r180"=180°, "r270"=270° counterclockwise.
Use for TTA. Default: None (random choice).
pProbability of applying the transform. Default: 1.0.
>>> 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)Affine3D: Sample continuous rotations with interpolation and optional scale or translation.