Skip to content
class

ElasticTransform

extends_DisplacementTransform
ElasticTransform(alpha: float = 1.0, sigma: float = 50.0, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Elastic deformation (Simard 2003; Albumentations ElasticTransform).

Random fields smoothed by a Gaussian then scaled by alpha.

Parameters

alphafloat= 1.0
Displacement magnitude.
sigmafloat= 50.0
Gaussian smoothing of the displacement field (pixels).
interpolationint or str or Interpolation= 1
No description.
pfloat= 0.5
No description.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ElasticTransform(p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(alpha: float = 1.0, sigma: float = 50.0, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Instance methods

1
fn

make_params

→DispParams
make_params(img: Tensor)

Sample per-call random parameters for ElasticTransform.

Parameters

Image tensor; its spatial size sets the displacement field size and the output canvas.

Returns

DispParams

Carries per-pixel dx / dy displacement fields of shape (H, W) in pixel units, built by sampling two uniform (1, 1, H, W) random fields in [-1, 1], blurring each with a Gaussian of sigma, and scaling by alpha — the Simard 2003 recipe. out_hw equals the input (H, W).

Dunder methods

1