ElasticTransform — Torchvision 0.22 documentation (original) (raw)

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:

Examples using ElasticTransform:

forward(tensor: Tensor) → Tensor[source]

Parameters:

tensor (PIL Image or Tensor) – Image to be transformed.

Returns:

Transformed image.

Return type:

PIL Image or Tensor