Albumentations to PIL/Pillow Transform Mapping

On this page

This page maps Albumentations transforms to Pillow operations where Pillow has a direct benchmark implementation. The source of truth for supported Pillow benchmark transforms is benchmark/transforms/pillow_impl.py; shared parameter names come from benchmark/transforms/specs.py.

If the Pillow column is -, Pillow has no direct analogue in the benchmark. The benchmark intentionally does not recreate Albumentations behavior with custom NumPy, ImageDraw, or handwritten target-propagation glue.

Channel and Target Caveats

Pillow operations are built around image modes such as L, RGB, and RGBA. Many color operations either convert to grayscale/RGB or assume RGB-style channels. Albumentations operates on NumPy arrays, so many image-only transforms can preserve arbitrary channel counts. RGB/color-space transforms still have channel-specific constraints.

Pillow transforms do not update masks, bounding boxes, keypoints, rotated boxes, volumes, or videos. Albumentations transforms are pipeline operations and can update supported targets in the same call.

Pillow also does not provide augmentation-policy containers comparable to Albumentations Compose, OneOf, SomeOf, or RandomOrder. Combining crop, flip, normalization, and optional branches means writing the policy as Python control flow. In Albumentations, the policy is a serializable pipeline object.

Direct Pillow Benchmark Mappings

Albumentations transformPillow operationNotes
ResizeImage.resizeDirect resize benchmark mapping. Albumentations also supports target propagation and separate mask interpolation.
HorizontalFlipImage.transpose(FLIP_LEFT_RIGHT)Same image operation; Albumentations also flips masks, boxes, and keypoints.
VerticalFlipImage.transpose(FLIP_TOP_BOTTOM)Same image operation; Albumentations also updates supported targets.
TransposeImage.transpose(TRANSPOSE)Useful for square-symmetry style augmentation.
RotateImage.rotateAlbumentations exposes border modes, fill values, bbox rotation behavior, and mask interpolation.
PadImageOps.expandDirect padding benchmark mapping.
AffineImage.transform(AFFINE)Albumentations keeps affine parameters in one transform and can update masks, boxes, and keypoints.
Affine with shearImage.transform(AFFINE)Benchmark maps the standalone shear spec to Pillow affine coefficients.
RandomBrightnessContrastImageEnhance.Brightness / ImageEnhance.ContrastPillow exposes brightness and contrast as separate enhancers; Albumentations commonly combines them.
HueSaturationValue / ColorJitterImageEnhance.ColorRGB/color-space operation. Not an arbitrary-channel transform.
AutoContrastImageOps.autocontrastAlbumentations adds probability and pipeline integration.
EqualizeImageOps.equalizeAlbumentations supports cv and pil modes plus mask-based equalization.
ToGrayImageOps.grayscale(...).convert("RGB")Albumentations has multiple grayscale methods and configurable output channels.
InvertImgImageOps.invertAlbumentations handles dtype-dependent maximum values.
PosterizeImageOps.posterizeAlbumentations supports fixed, random, and per-channel bit settings.
SolarizeImageOps.solarizeAlbumentations uses normalized threshold ranges and handles dtype scaling.
ColorizeImageOps.colorizeBoth are colorization operations; Albumentations exposes sampled color ranges.
DitheringImage.convert("1", dither=...)Pillow supports Floyd-Steinberg style dithering; Albumentations exposes benchmarked dithering parameters.
GaussianBlurImageFilter.GaussianBlurAlbumentations can sample blur limits and sigma ranges.
MedianBlurImageFilter.MedianFilterAlbumentations enforces valid odd kernel sizes.
BlurImageFilter.BoxBlurClose average/box blur equivalent.
UnsharpMaskImageFilter.UnsharpMaskAlbumentations exposes blur, sigma, alpha, and threshold ranges.
EnhanceImageFilter.EDGE_ENHANCE_MORE / ImageFilter.DETAILBenchmark maps edge and detail enhancement to Pillow filter constants.
ImageCompressionJPEG save/load roundtripAlbumentations supports JPEG and WebP compression simulation.

No Direct Pillow Benchmark Implementation

Albumentations transformPillow operationNotes
RandomCrop-Pillow can crop pixels, but the benchmark has no direct random-crop augmentation primitive with target semantics.
RandomResizedCrop-No direct Pillow benchmark implementation for sampled crop plus resize.
CenterCrop-No direct Pillow benchmark implementation.
RandomRotate90-No direct Pillow benchmark implementation. Use Albumentations when 90-degree rotations are part of the augmentation policy.
SquareSymmetry-Pillow has transpose primitives, but no direct benchmark implementation for the full 8-way square symmetry policy.
SafeRotate-No direct Pillow benchmark implementation for rotation that preserves full image content.
RandomScale-No direct Pillow benchmark implementation.
ShiftScaleRotate-No direct Pillow benchmark implementation for the combined augmentation primitive.
Perspective-No direct Pillow benchmark implementation.
ElasticTransform-No direct Pillow benchmark implementation for sampled elastic deformation.
GridDistortion-No direct Pillow benchmark implementation for grid-based non-rigid distortion.
ThinPlateSpline-No direct Pillow benchmark implementation for smooth control-point deformation.
OpticalDistortion-No direct Pillow benchmark implementation for lens/fisheye distortion.
RandomGridShuffle-No direct Pillow benchmark implementation.
Morphological-No direct Pillow benchmark implementation for morphology operations.
PadIfNeeded-Pillow can pad pixels, but the benchmark has no direct minimum-size padding primitive.
CropAndPad-No direct Pillow benchmark implementation.
RandomSizedCrop-No direct Pillow benchmark implementation.
BBoxSafeRandomCrop-Pillow has no concept of boxes or visibility constraints.
RandomSizedBBoxSafeCrop-Pillow has no concept of boxes or visibility constraints.
GaussNoise-No direct Pillow benchmark implementation for sampled Gaussian noise.
AdditiveNoise-No direct Pillow benchmark implementation.
MultiplicativeNoise-No direct Pillow benchmark implementation.
ShotNoise-No direct Pillow benchmark implementation.
ISONoise-No direct Pillow benchmark implementation.
RandomGamma-No direct Pillow benchmark implementation.
CLAHE-No direct Pillow benchmark implementation.
MotionBlur-No direct Pillow benchmark implementation.
Emboss-No direct Pillow benchmark implementation.
ChromaticAberration-No direct Pillow benchmark implementation.
Downscale-No direct Pillow benchmark implementation for downscale-upscale degradation.
PixelSpread-No direct Pillow benchmark implementation.
RandomToneCurve-No direct Pillow benchmark implementation.
RingingOvershoot-No direct Pillow benchmark implementation.
Spatter-No direct Pillow benchmark implementation.
FancyPCA-No direct Pillow benchmark implementation.
Superpixels-No direct Pillow benchmark implementation.
ToSepia-No direct Pillow benchmark implementation.
ChannelShuffle-No direct Pillow benchmark implementation.
ChannelDropout-No direct Pillow benchmark implementation.
ChannelSwap-No direct Pillow benchmark implementation.
Normalize-Pillow image modes are not a general normalization contract for arbitrary-channel training tensors.
CoarseDropout-You would write region sampling, fill rules, and target behavior manually.
GridDropout-No direct Pillow benchmark implementation.
PixelDropout-No direct Pillow benchmark implementation.
ConstrainedCoarseDropout-No direct Pillow benchmark implementation for object-constrained dropout.
RandomFog-Pillow provides drawing/filter primitives, not a tested fog augmentation transform.
RandomRain-Pillow provides drawing/filter primitives, not a tested rain augmentation transform.
RandomSnow-Pillow provides drawing/filter primitives, not a tested snow augmentation transform.
RandomShadow-No direct Pillow benchmark implementation.
RandomSunFlare-No direct Pillow benchmark implementation.
Illumination-No direct Pillow benchmark implementation for linear, corner, or Gaussian illumination modes.
PlasmaBrightnessContrast-No direct Pillow benchmark implementation.
PlasmaShadow-No direct Pillow benchmark implementation.
AtmosphericFog-No direct Pillow benchmark implementation.
Vignetting-No direct Pillow benchmark implementation.
FilmGrain-No direct Pillow benchmark implementation.
Halftone-No direct Pillow benchmark implementation.
LensFlare-No direct Pillow benchmark implementation.
GridMask-No direct Pillow benchmark implementation.
CopyAndPaste-No direct Pillow benchmark implementation for annotation-aware copy-paste.
WaterRefraction-No direct Pillow benchmark implementation.

Migration Pattern

from PIL import Image
import numpy as np
import albumentations as A

image = np.array(Image.open("image.jpg").convert("RGB"))

pipeline = A.Compose([
    A.HorizontalFlip(p=0.5),
    A.Rotate(angle_range=(-45, 45), border_mode=0, fill=0, p=0.5),
    A.OneOf([
        A.GaussianBlur(blur_range=(3, 7), p=1.0),
        A.GaussNoise(std_range=(0.05, 0.2), p=1.0),
    ], p=0.3),
    A.RandomBrightnessContrast(brightness_range=(-0.2, 0.2), contrast_range=(-0.2, 0.2), p=0.5),
])

augmented = pipeline(image=image)["image"]

For non-RGB data, keep the array shape you actually train on and avoid RGB-only transforms unless the conversion is intentional.

Because this is an Albumentations pipeline object, you can serialize it and reuse the same augmentation definition outside the notebook or training script.

Benchmark Pages