Skip to content
class

ShiftScaleRotate

extends_WarpTransform
ShiftScaleRotate(shift_limit: float | tuple[float, float] = 0.0625, scale_limit: float | tuple[float, float] = 0.1, rotate_limit: float | tuple[float, float] = 45, interpolation: int | str | Interpolation = 1, border_mode: int = 4, value: float = 0.0, p: float = 0.5)

Random shift + scale + rotation (Albumentations ShiftScaleRotate).

Parameters

shift_limitfloat or (float, float)= 0.0625
Fraction-of-size translation range (applied to both axes).
scale_limitfloat or (float, float)= 0.1
Scale-delta range (effective scale is 1 + s).
rotate_limitfloat or (float, float)= 45
Rotation-angle range in degrees.
interpolationint | str | Interpolation= 1
As in Rotate.
border_modeint | str | Interpolation= 1
As in Rotate.
valueint | str | Interpolation= 1
As in Rotate.
pint | str | Interpolation= 1
As in Rotate.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ShiftScaleRotate(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__(shift_limit: float | tuple[float, float] = 0.0625, scale_limit: float | tuple[float, float] = 0.1, rotate_limit: float | tuple[float, float] = 45, 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 ShiftScaleRotate.

Parameters

Image tensor; its spatial size is read to anchor the warp and to convert shift_limit from a fraction-of-size into pixel translations.

Returns

WarpParams

Carries the composed (3, 3) matrix (rotate about the image centre, then scale and translate) and out_hw equal to the input (H, W).

Notes

The sampled rotation angle is negated when fed to affine_matrix to align the math-convention CCW rotation with the cv2 / image-convention CW rotation used by Rotate.

Dunder methods

1