Apply random cubic symmetry (one of 48) to a 3D volume. No interpolation; remaps voxels. 3D extension of D4. For TTA or augmentation; inverse() supported.
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 volumes 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"]