Randomly reorient a 3D volume with one of 48 exact cubic symmetries, using only axis permutations and reflections for interpolation-free augmentation.
This transform is intended for augmentation. Use a transform with explicit deterministic parameters for TTA.
This transform is a 3D extension of D4. While D4 handles the 8 symmetries of a square (4 rotations x 2 reflections), CubicSymmetry handles all 48 symmetries of a cube. Like D4, this transform does not create any interpolation artifacts as it only remaps voxels from one position to another without any interpolation.
The 48 transformations consist of:
For a cube, these transformations preserve:
works with 3D volume data and masks of the shape (D, H, W) or (D, H, W, C)
pProbability of applying the transform. Default: 1.0
>>> import numpy as np
>>> import albumentations as A
>>> volume = np.random.randint(0, 256, (10, 100, 100), dtype=np.uint8) # (D, H, W)
>>> mask3d = np.random.randint(0, 2, (10, 100, 100), dtype=np.uint8) # (D, H, W)
>>> transform = A.CubicSymmetry(p=1.0)
>>> transformed = transform(volume=volume, mask3d=mask3d)
>>> transformed_volume = transformed["volume"]
>>> transformed_mask3d = transformed["mask3d"]