Simulate smooth MRI intensity inhomogeneity by multiplying images and volumes by a positive field sampled on a coarse spatial grid.
The transform samples zero-mean Gaussian log-gain coefficients, interpolates them across all spatial axes, and exponentiates the result. The field changes tissue intensity across space while preserving anatomy labels.
std_rangeNondecreasing range in [0, 1] for the coarse log-gain standard deviation.
Larger values produce stronger intensity variation. Zero gives exact identity. Default: (0.0, 0.5).
scale_rangeNondecreasing range in (0, 1] for the ratio of coarse axis length
to input axis length.
Smaller values produce smoother fields; 1.0 uses an unsmoothed voxel-wise log-gain grid.
Each non-singleton coarse axis has at least two points. Default: (0.025, 0.025).
per_channelIf True, sample independent log-gain coefficients for each channel. If False,
share one field across channels. Default: False.
pProbability of applying the transform. Default: 0.5.
>>> import albumentations as A
>>> import numpy as np
>>> volume = np.full((16, 64, 96, 1), 0.25, dtype=np.float32)
>>> mask3d = np.zeros((16, 64, 96), dtype=np.uint8)
>>> pipeline = A.Compose([
... A.BiasField(std_range=(0.1, 0.3), scale_range=(0.02, 0.04), p=1),
... ], seed=137, strict=True)
>>> result = pipeline(volume=volume, mask3d=mask3d)
>>> result["volume"].shape
(16, 64, 96, 1)(H, W); volumes use trilinear interpolation over (D, H, W).
Singleton axes remain singleton. Batch elements and aligned additional targets share sampled coefficients.min(size, max(2, int(size * scale))). The standard deviation describes
the coarse coefficients; interpolation generally reduces the final log-field variance.exp(interpolated_log_gain). Results are clipped to [0, 1] for float32
and rounded back into [0, 255] for uint8. Clipping can change contrast near the intensity maximum.std=0.5 and scale=0.025 as reference MRI settings. The default range samples up to
that strength. Strong fields can obscure tissue contrast or alter clinical semantics; inspect augmented
examples for the intended anatomy and task.