Skip to content
class

OpticalDistortion

extends_DisplacementTransform
OpticalDistortion(distort_limit: float | tuple[float, float] = 0.05, shift_limit: float | tuple[float, float] = 0.05, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Radial (barrel / pincushion) distortion (Albumentations OpticalDistortion).

Parameters

distort_limitfloat or (float, float)= 0.05
Radial coefficient range.
shift_limitfloat or (float, float)= 0.05
Optical-center shift range (fraction of size).
interpolationint or str or Interpolation= 1
No description.
pfloat= 0.5
No description.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.OpticalDistortion(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__(distort_limit: float | tuple[float, float] = 0.05, shift_limit: float | tuple[float, float] = 0.05, 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 OpticalDistortion.

Parameters

Image tensor; its spatial size sets the displacement field size, the centred normalisation, and out_hw.

Returns

DispParams

Carries per-pixel dx / dy fields of shape (H, W) realising the radial backward map sample(p) = c + (p - c) * (1 + k * r^2) with k drawn uniformly from distort_limit and the optical centre c shifted from the image centre by shift_limit fractions. out_hw equals the input (H, W).

Dunder methods

1