Resize a volume to a fixed (depth, height, width) shape, preserving all channels, dtype, and its public layout intact.
Resize3D resamples all three spatial axes together; depth is never treated as a
batch axis. Single-volume intensity data and categorical masks use independently configurable
interpolation. The routed Albucore backend supports only linear and nearest-neighbor
interpolation, ensuring the same public contract for NumPy and CPU Tensor inputs.
sizeTarget spatial shape in (depth, height, width) order.
interpolationInterpolation for a volume: cv2.INTER_LINEAR or
cv2.INTER_NEAREST. Default: cv2.INTER_LINEAR.
mask_interpolationInterpolation for mask3d:
cv2.INTER_LINEAR or cv2.INTER_NEAREST. Default: cv2.INTER_NEAREST.
pProbability of applying the transform. Default: 1.0.
>>> import albumentations as A
>>> import cv2
>>> import numpy as np
>>> volume = np.random.default_rng(137).random((16, 64, 96, 1), dtype=np.float32)
>>> mask3d = np.zeros((16, 64, 96), dtype=np.uint8)
>>> transform = A.Compose([
... A.Resize3D(
... size=(32, 128, 128),
... interpolation=cv2.INTER_LINEAR,
... mask_interpolation=cv2.INTER_NEAREST,
... ),
... ])
>>> result = transform(volume=volume, mask3d=mask3d)
>>> result["volume"].shape, result["mask3d"].shape
((32, 128, 128, 1), (32, 128, 128))(D, H, W, C) layout. CPU Tensor volume data
use channel-first (C, D, H, W) layout.uint8 output preserves dtype; linear resampling rounds and saturates to
[0, 255]. Float32 output remains float32.(x, y, z) order and scale from the voxel-grid origin by
(W2 / W1, H2 / H1, D2 / D1), matching the 2D resize convention.Affine3D: Sample continuous rotations, scales, and translations while keeping the input output grid.