CoarseDropout3D
CoarseDropout3D randomly drops out cuboid regions from a 3D volume and optionally, the corresponding regions in an associated 3D mask, to simulate occlusion and varied object sizes found in real-world volumetric data.
Supported Targets
keypoints
Arguments
NameTypeDefaultDescription
num_holes_range
tuple[int, int]
Range (min, max) for the number of cuboid regions to drop out. Default: (1, 1)
hole_depth_range
tuple[float, float]
Range (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_range
tuple[float, float]
Range (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_range
tuple[float, float]
Range (min, max) for the width of dropout regions as a fraction of the volume width (between 0 and 1). Default: (0.1, 0.2)
fill
tuple[float, float] | float
Value for the dropped voxels. Can be: - int or float: all channels are filled with this value - tuple: tuple of values for each channel Default: 0
fill_mask
tuple[float, float] | float | None
Fill value for dropout regions in the 3D mask. If None, mask regions corresponding to volume dropouts are unchanged. Default: None
p
float
Probability of applying the transform. Default: 0.5
Image Types
uint8, float32
Notes
- The actual number and size of dropout regions are randomly chosen within the specified ranges. - All values in hole_depth_range, hole_height_range and hole_width_range must be between 0 and 1. - If you want to apply dropout only in the XY plane while preserving the full depth dimension, consider using CoarseDropout instead. CoarseDropout will apply the same rectangular dropout to each slice independently, effectively creating cylindrical dropout regions that extend through the entire depth of the volume.
Examples
>>> 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"]