Randomly drop cuboid regions from a 3D volume (and optionally mask) to simulate occlusion. Hole size/count configurable.
num_holes_rangeRange (min, max) for the number of cuboid regions to drop out. Default: (1, 1)
hole_depth_rangeRange (min, max) for the depth of dropout regions as a fraction of the volume depth (between 0 and 1). Default: (0.1, 0.2)
hole_height_rangeRange (min, max) for the height of dropout regions as a fraction of the volume height (between 0 and 1). Default: (0.1, 0.2)
hole_width_rangeRange (min, max) for the width of dropout regions as a fraction of the volume width (between 0 and 1). Default: (0.1, 0.2)
fillValue for the dropped voxels. Can be:
fill_maskFill value for dropout regions in the 3D mask. If None, mask regions corresponding to volume dropouts are unchanged. Default: None
pProbability of applying the transform. Default: 0.5
>>> 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)
>>> aug = A.CoarseDropout3D(
... num_holes_range=(3, 6),
... hole_depth_range=(0.1, 0.2),
... hole_height_range=(0.1, 0.2),
... hole_width_range=(0.1, 0.2),
... fill=0,
... p=1.0
... )
>>> transformed = aug(volume=volume, mask3d=mask3d)
>>> transformed_volume, transformed_mask3d = transformed["volume"], transformed["mask3d"]