Skip to content

Geometric functional transforms (augmentations.geometric.functional)

def albumentations.augmentations.geometric.functional.bbox_rot90(bbox, factor, rows, cols) [view source on GitHub]

Rotates a bounding box by 90 degrees CCW (see np.rot90)

Parameters:

Name Type Description
bbox tuple

A bounding box tuple (x_min, y_min, x_max, y_max).

factor int

Number of CCW rotations. Must be in set {0, 1, 2, 3} See np.rot90.

rows int

Image rows.

cols int

Image cols.

Returns:

Type Description
tuple

A bounding box tuple (x_min, y_min, x_max, y_max).

def albumentations.augmentations.geometric.functional.bbox_rotate(bbox, angle, rows, cols) [view source on GitHub]

Rotates a bounding box by angle degrees.

Parameters:

Name Type Description
bbox tuple

A bounding box (x_min, y_min, x_max, y_max).

angle int

Angle of rotation in degrees.

rows int

Image rows.

cols int

Image cols.

Returns:

Type Description

A bounding box (x_min, y_min, x_max, y_max).

def albumentations.augmentations.geometric.functional.elastic_transform(img, alpha, sigma, alpha_affine, interpolation=1, border_mode=4, value=None, random_state=None, approximate=False) [view source on GitHub]

Elastic deformation of images as described in [Simard2003]_ (with modifications). Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5

.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for Convolutional Neural Networks applied to Visual Document Analysis", in Proc. of the International Conference on Document Analysis and Recognition, 2003.

def albumentations.augmentations.geometric.functional.keypoint_rot90(keypoint, factor, rows, cols, **params) [view source on GitHub]

Rotates a keypoint by 90 degrees CCW (see np.rot90)

Parameters:

Name Type Description
keypoint tuple

A keypoint (x, y, angle, scale).

factor int

Number of CCW rotations. Must be in range [0;3] See np.rot90.

rows int

Image height.

cols int

Image width.

Returns:

Type Description
tuple

A keypoint (x, y, angle, scale).

Exceptions:

Type Description
ValueError

if factor not in set {0, 1, 2, 3}

def albumentations.augmentations.geometric.functional.keypoint_rotate(keypoint, angle, rows, cols, **params) [view source on GitHub]

Rotate a keypoint by angle.

Parameters:

Name Type Description
keypoint tuple

A keypoint (x, y, angle, scale).

angle float

Rotation angle.

rows int

Image height.

cols int

Image width.

Returns:

Type Description
tuple

A keypoint (x, y, angle, scale).

def albumentations.augmentations.geometric.functional.keypoint_scale(keypoint, scale_x, scale_y) [view source on GitHub]

Scales a keypoint by scale_x and scale_y.

Parameters:

Name Type Description
keypoint Sequence[float]

A keypoint (x, y, angle, scale).

scale_x float

Scale coefficient x-axis.

scale_y float

Scale coefficient y-axis.

Returns:

Type Description

A keypoint (x, y, angle, scale).

def albumentations.augmentations.geometric.functional.py3round(number) [view source on GitHub]

Unified rounding in all python versions.