ElasticTransform¶
- class torchvision.transforms.ElasticTransform(alpha=50.0, sigma=5.0, interpolation=InterpolationMode.BILINEAR, fill=0)[source]¶
Transform a tensor image with elastic transformations. Given alpha and sigma, it will generate displacement vectors for all pixels based on random offsets. Alpha controls the strength and sigma controls the smoothness of the displacements. The displacements are added to an identity grid and the resulting grid is used to grid_sample from the image.
- Applications:
Randomly transforms the morphology of objects in images and produces a see-through-water-like effect.
- Parameters:
alpha (float or sequence of python:floats) – Magnitude of displacements. Default is 50.0.
sigma (float or sequence of python:floats) – Smoothness of displacements. Default is 5.0.
interpolation (InterpolationMode) – Desired interpolation enum defined by
torchvision.transforms.InterpolationMode
. Default isInterpolationMode.BILINEAR
. If input is Tensor, onlyInterpolationMode.NEAREST
,InterpolationMode.BILINEAR
are supported. The corresponding Pillow integer constants, e.g.PIL.Image.BILINEAR
are accepted as well.fill (sequence or number) – Pixel fill value for the area outside the transformed image. Default is
0
. If given a number, the value is used for all bands respectively.
Examples using
ElasticTransform
:Illustration of transforms