Pad3D
Pad the sides of a 3D volume by specified number of voxels.
Supported Targets
keypoints
Arguments
Name | Type | Default | Description |
---|---|---|---|
padding | int, tuple[int, int, int] or tuple[int, int, int, int, int, int] | Padding values. Can be: * int - pad all sides by this value * tuple[int, int, int] - symmetric padding (depth, height, width) where each value is applied to both sides of the corresponding dimension * tuple[int, int, int, int, int, int] - explicit padding per side in order: (depth_front, depth_back, height_top, height_bottom, width_left, width_right) | |
fill | tuple[float, ...] | float | Padding value for image | |
fill_mask | tuple[float, ...] | float | Padding value for mask | |
p | float | probability of applying the transform. Default: 1.0. |
Image Types
uint8, float32
Notes
Input volume should be a numpy array with dimensions ordered as (z, y, x) or (depth, height, width),
with optional channel dimension as the last axis.
Examples
>>> import numpy as np
>>> import albumentations as A
>>>
>>> # Prepare sample data
>>> 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)
>>> keypoints = np.array([[20, 30, 5], [60, 70, 8]], dtype=np.float32) # (x, y, z)
>>> keypoint_labels = [1, 2] # Labels for each keypoint
>>>
>>> # Create the transform with symmetric padding
>>> transform = A.Compose([
... A.Pad3D(
... padding=(2, 5, 10), # (depth, height, width) applied symmetrically
... fill=0,
... fill_mask=1,
... p=1.0
... )
... ], keypoint_params=A.KeypointParams(format='xyz', label_fields=['keypoint_labels']))
>>>
>>> # Apply the transform
>>> transformed = transform(
... volume=volume,
... mask3d=mask3d,
... keypoints=keypoints,
... keypoint_labels=keypoint_labels
... )
>>>
>>> # Get the transformed data
>>> padded_volume = transformed["volume"] # Shape: (14, 110, 120)
>>> padded_mask3d = transformed["mask3d"] # Shape: (14, 110, 120)
>>> padded_keypoints = transformed["keypoints"] # Keypoints shifted by padding
>>> padded_keypoint_labels = transformed["keypoint_labels"] # Labels remain unchanged