Skip to content
class

Perspective

extends_WarpTransform
Perspective(scale: float | tuple[float, float] = (0.05, 0.1), interpolation: int | str | Interpolation = 1, border_mode: int = 4, value: float = 0.0, p: float = 0.5)

Random four-point perspective warp (Albumentations Perspective).

Parameters

scalefloat or (float, float)= (0.05, 0.1)
Std (as a fraction of size) of the random corner displacement.
interpolationint | str | Interpolation= 1
As in Rotate. keep_size is implicit (output keeps the input size).
border_modeint | str | Interpolation= 1
As in Rotate. keep_size is implicit (output keeps the input size).
valueint | str | Interpolation= 1
As in Rotate. keep_size is implicit (output keeps the input size).
pint | str | Interpolation= 1
As in Rotate. keep_size is implicit (output keeps the input size).

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.Perspective(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__(scale: float | tuple[float, float] = (0.05, 0.1), interpolation: int | str | Interpolation = 1, border_mode: int = 4, value: float = 0.0, p: float = 0.5)

Instance methods

1
fn

make_params

→WarpParams
make_params(img: Tensor)

Sample per-call random parameters for Perspective.

Parameters

Image tensor; its spatial size is read to scale the per-corner displacement and to set out_hw.

Returns

WarpParams

Carries the (3, 3) homography mapping the perturbed corners back to the canvas and out_hw equal to the input (H, W).

Dunder methods

1