Simulate Gibbs ringing near sharp intensity boundaries by truncating high-frequency k-space in an image or a whole 3D volume.
A hard rectangular frequency cutoff creates oscillations and reduces spatial resolution. Use it to model finite Cartesian acquisition bandwidth; it is a generic artifact simulation, not a correction algorithm.
retained_fraction_rangeNondecreasing range in [0, 1] for the fraction of
the frequency bandwidth retained along every spatial axis. Smaller values remove more frequencies.
One is an exact identity; zero keeps only DC, giving each channel its spatial mean.
Default: (0.5, 0.9).
pProbability of applying the transform. Default: 0.5.
>>> import albumentations as A
>>> import numpy as np
>>> image = np.zeros((64, 96, 1), dtype=np.float32)
>>> image[16:48, 24:72] = 0.75
>>> transform = A.GibbsRinging(retained_fraction_range=(0.4, 0.8), p=1)
>>> augmented = transform(image=image)["image"]
>>> volume = np.zeros((16, 64, 96, 1), dtype=np.float32)
>>> volume[4:12, 16:48, 24:72] = 0.75
>>> pipeline = A.Compose([transform], seed=137, strict=True)
>>> result = pipeline(volume=volume)["volume"]
>>> result.shape
(16, 64, 96, 1)Compose normalizes optional channel axes. Direct calls use explicit channel-last (H, W, C)
images or (D, H, W, C) volumes.(H, W) for images and (D, H, W) for volumes, including singleton depth.
Channels and collection items are independent signals with one shared sampled cutoff fraction.N, retain signed frequency indices with
abs(k) <= floor(retained_fraction * N / 2). DC is always included. Even-length Nyquist bins
are retained only when the cutoff reaches N / 2; odd lengths use their actual signed bins.[0, 1].
Floating reconstruction is clipped to [0, 1]; uint8 is processed in float32 and rounded back
into [0, 255]. Clipping can change the mean.