Skip to content
class

GridDistortion

extends_DisplacementTransform
GridDistortion(num_steps: int = 5, distort_limit: float | tuple[float, float] = 0.3, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Grid distortion (Albumentations GridDistortion).

Perturbs a coarse num_steps x num_steps control grid by distort_limit and upsamples it to a smooth displacement field.

Parameters

num_stepsint= 5
No description.
distort_limitfloat or (float, float)= 0.3
No description.
interpolationint or str or Interpolation= 1
No description.
pfloat= 0.5
No description.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.GridDistortion(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__(num_steps: int = 5, distort_limit: float | tuple[float, float] = 0.3, 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 GridDistortion.

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 a (num_steps + 1) x (num_steps + 1) control grid with entries in distort_limit (scaled by the cell size in each axis) and bilinearly upsampling to (H, W). out_hw equals the input (H, W).

Dunder methods

1