- Support Our Work
- Transforms
- Core
- Bugfixes
Support Our Work
- Help Us Grow - If you find value in Albumentations, consider becoming a sponsor. Every contribution, no matter the size, helps us maintain and improve the library for everyone.
- Show Your Support - If you enjoy using Albumentations, consider giving us a ⭐ on GitHub. It helps others discover the library and motivates our team.
- Join Our Community - Have suggestions or ran into issues? We welcome your input! Share your experience in our GitHub issues or connect with us on Discord.
Transforms
Elastic Transform
- Added argument
noise_distribution
that allows sampling displacement fields fromgaussian
and fromuniform
distributions. - Deprecated parameters
border_mode
,value
,mask_value
- you can specify them, but will not have any effect.
New transform ShotNoise
Apply shot noise to the image by modeling photon counting as a Poisson process.
Shot noise (also known as Poisson noise) occurs in imaging due to the quantum nature of light.
When photons hit an imaging sensor, they arrive at random times following Poisson statistics.
This transform simulates this physical process in linear light space by:
1. Converting to linear space (removing gamma)
2. Treating each pixel value as an expected photon count
3. Sampling actual photon counts from a Poisson distribution
4. Converting back to display space (reapplying gamma)
The noise characteristics follow real camera behavior:
- Noise variance equals signal mean in linear space (Poisson statistics)
- Brighter regions have more absolute noise but less relative noise
- Darker regions have less absolute noise but more relative noise
- Noise is generated independently for each pixel and color channel
RandomGridShuffle
Addes support for bounding boxes
CorseDropout
Added an option to inpaint holes using inpaint_ns
and inpaint_telea
from OpenCV
GridDropout
Added an option to inpaint holes using inpaint_ns
and inpaint_telea
from OpenCV
MaskDropout
Added an option to inpaint holes using inpaint_ns
and inpaint_telea
from OpenCV
XYMasking
Added an option to inpaint holes using inpaint_ns
and inpaint_telea
from OpenCV
New transform TimeReverse
Added NewTransform TimeReverse
Reverse the time axis of a spectrogram image, also known as time inversion.
Time inversion of a spectrogram is analogous to the random flip of an image,
an augmentation technique widely used in the visual domain. This can be relevant
in the context of audio classification tasks when working with spectrograms.
The technique was successfully applied in the AudioCLIP paper, which extended
CLIP to handle image, text, and audio inputs.
This transform is implemented as a subclass of HorizontalFlip since reversing
time in a spectrogram is equivalent to flipping the image horizontally.
New transform TimeMasking
Added NewTransform TimeMasking
Apply masking to a spectrogram in the time domain.
This transform masks random segments along the time axis of a spectrogram,
implementing the time masking technique proposed in the SpecAugment paper.
Time masking helps in training models to be robust against temporal variations
and missing information in audio signals.
This is a specialized version of XYMasking configured for time masking only.
For more advanced use cases (e.g., multiple masks, frequency masking, or custom
fill values), consider using XYMasking directly.
New transform FrequencyMasking
Apply masking to a spectrogram in the frequency domain.
This transform masks random segments along the frequency axis of a spectrogram,
implementing the frequency masking technique proposed in the SpecAugment paper.
Frequency masking helps in training models to be robust against frequency variations
and missing spectral information in audio signals.
This is a specialized version of XYMasking configured for frequency masking only.
For more advanced use cases (e.g., multiple masks, time masking, or custom
fill values), consider using XYMasking directly.
Added NewTransform FrequencyMasking
It is a specialized version of XYMasking that has the similar API as FrequencyMasking from torchaudio
New Transform Pad
Pad the sides of an image by specified number of pixels.
Args:
padding (int, tuple[int, int] or tuple[int, int, int, int]): Padding values. Can be:
* int - pad all sides by this value
* tuple[int, int] - (pad_x, pad_y) to pad left/right by pad_x and top/bottom by pad_y
* tuple[int, int, int, int] - (left, top, right, bottom) specific padding per side
This is the generalization of the torchvision transform with the same name
New Transform Erasing
This is the generalization of the similar torchvision transform
Randomly erases rectangular regions in an image, following the Random Erasing Data Augmentation technique.
This augmentation helps improve model robustness by randomly masking out rectangular regions in the image,
simulating occlusions and encouraging the model to learn from partial information. It's particularly
effective for image classification and person re-identification tasks.
New Transform AdditiveNoise
Apply random noise to image channels using various noise distributions.
This transform generates noise using different probability distributions and applies it
to image channels. The noise can be generated in three spatial modes and supports
multiple noise distributions, each with configurable parameters.
Args:
noise_type: Type of noise distribution to use. Options:
- "uniform": Uniform distribution, good for simple random perturbations
- "gaussian": Normal distribution, models natural random processes
- "laplace": Similar to Gaussian but with heavier tails, good for outliers
- "beta": Flexible bounded distribution, can be symmetric or skewed
spatial_mode: How to generate and apply the noise. Options:
- "constant": One noise value per channel, fastest
- "per_pixel": Independent noise value for each pixel and channel, slowest
- "shared": One noise map shared across all channels, medium speed
Sharpen
Added 'gaussian' method for image sharpening.
New transform SaltAndPepper
Apply salt and pepper noise to the input image.
Salt and pepper noise is a form of impulse noise that randomly sets pixels to either maximum value (salt)
or minimum value (pepper). The amount and proportion of salt vs pepper noise can be controlled.
New transform PlasmaBrightNessContrast
Apply plasma fractal pattern to modify image brightness and contrast.
This transform uses the Diamond-Square algorithm to generate organic-looking fractal patterns
that are then used to create spatially-varying brightness and contrast adjustments.
The result is a natural-looking, non-uniform modification of the image.
New Transform PlasmaShadow
Apply plasma-based shadow effect to the image.
Creates organic-looking shadows using plasma fractal noise pattern.
The shadow intensity varies smoothly across the image, creating natural-looking
darkening effects that can simulate shadows, shading, or lighting variations.
New args in MotionBlur
Added angle_range
and direction_range
parameters.
Apply motion blur to the input image using a directional kernel.
This transform simulates motion blur effects that occur during image capture,
such as camera shake or object movement. It creates a directional blur using
a line-shaped kernel with controllable angle, direction, and position.
Args:
blur_limit (int | tuple[int, int]): Maximum kernel size for blurring.
Should be in range [3, inf).
- If int: kernel size will be randomly chosen from [3, blur_limit]
- If tuple: kernel size will be randomly chosen from [min, max]
Larger values create stronger blur effects.
Default: (3, 7)
angle_range (tuple[float, float]): Range of possible angles in degrees.
Controls the rotation of the motion blur line:
- 0°: Horizontal motion blur →
- 45°: Diagonal motion blur ↗
- 90°: Vertical motion blur ↑
- 135°: Diagonal motion blur ↖
Default: (0, 360)
direction_range (tuple[float, float]): Range for motion bias.
Controls how the blur extends from the center:
- -1.0: Blur extends only backward (←)
- 0.0: Blur extends equally in both directions (←→)
- 1.0: Blur extends only forward (→)
For example, with angle=0:
- direction=-1.0: ←•
- direction=0.0: ←•→
- direction=1.0: •→
Default: (-1.0, 1.0)
New Transform ThinPlateSpline
Apply Thin Plate Spline (TPS) transformation to create smooth, non-rigid deformations.
Imagine the image printed on a thin metal plate that can be bent and warped smoothly:
- Control points act like pins pushing or pulling the plate
- The plate resists sharp bending, creating smooth deformations
- The transformation maintains continuity (no tears or folds)
- Areas between control points are interpolated naturally
The transform works by:
1. Creating a regular grid of control points (like pins in the plate)
2. Randomly displacing these points (like pushing/pulling the pins)
3. Computing a smooth interpolation (like the plate bending)
4. Applying the resulting deformation to the image
New transform Illumination
Apply various illumination effects to the image.
This transform simulates different lighting conditions by applying controlled
illumination patterns. It can create effects like:
- Directional lighting (linear mode)
- Corner shadows/highlights (corner mode)
- Spotlights or local lighting (gaussian mode)
These effects can be used to:
- Simulate natural lighting variations
- Add dramatic lighting effects
- Create synthetic shadows or highlights
- Augment training data with different lighting conditions
Args:
mode (Literal["linear", "corner", "gaussian"]): Type of illumination pattern:
- 'linear': Creates a smooth gradient across the image,
simulating directional lighting like sunlight
through a window
- 'corner': Applies gradient from any corner,
simulating light source from a corner
- 'gaussian': Creates a circular spotlight effect,
simulating local light sources
Default: 'linear'
OpticalDistortion
- Added
fisheye
method. - Deprecated
border_mode
,value
,mask_value
New transform Autocontrast
Apply random auto contrast to images.
Auto contrast enhances image contrast by stretching the intensity range
to use the full range while preserving relative intensities. For each
color channel:
1. Compute histogram
2. Find cumulative percentiles
3. Clip and scale intensities to full range
Core
Unified naming for border_mode and filling constants.
value
,fill_value
,cval
,pad_val
=>fill
mask_value
,cval_mask
,fill_mask_value
,pad_mask_value
=>fill_mask
pad_mode
,mode
=>border_mode
by @ternaus
Bugfixes
- BugFix in RandomShadow, bow, larger intensity parameter will correspond to a darker shadow
- Bugfix in Load From Hub by @qubvel
- Bugfix in MotionBlur by @huuquan1994