Skip to content

Crop functional transforms (augmentations.crops.functional)

def albumentations.augmentations.crops.functional.bbox_crop(bbox, x_min, y_min, x_max, y_max, rows, cols) [view source on GitHub]

Crop a bounding box.

Parameters:

Name Type Description
bbox Union[List[int], List[float], Tuple[int, ...], Tuple[float, ...], numpy.ndarray]

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

x_min int
y_min int
x_max int
y_max int
rows int

Image rows.

cols int

Image cols.

Returns:

Type Description
tuple

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

def albumentations.augmentations.crops.functional.crop_bbox_by_coords(bbox, crop_coords, crop_height, crop_width, rows, cols) [view source on GitHub]

Crop a bounding box using the provided coordinates of bottom-left and top-right corners in pixels and the required height and width of the crop.

Parameters:

Name Type Description
bbox Union[List[int], List[float], Tuple[int, ...], Tuple[float, ...], numpy.ndarray]

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

crop_coords Tuple[int, int, int, int]

Crop coordinates (x1, y1, x2, y2).

crop_height int
crop_width int
rows int

Image rows.

cols int

Image cols.

Returns:

Type Description
tuple

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

def albumentations.augmentations.crops.functional.crop_keypoint_by_coords(keypoint, crop_coords) [view source on GitHub]

Crop a keypoint using the provided coordinates of bottom-left and top-right corners in pixels and the required height and width of the crop.

Parameters:

Name Type Description
keypoint Union[List[int], List[float], Tuple[int, ...], Tuple[float, ...], numpy.ndarray]

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

crop_coords Tuple[int, int, int, int]

Crop box coords (x1, x2, y1, y2).

Returns:

Type Description

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

def albumentations.augmentations.crops.functional.keypoint_center_crop(keypoint, crop_height, crop_width, rows, cols) [view source on GitHub]

Keypoint center crop.

Parameters:

Name Type Description
keypoint Union[List[int], List[float], Tuple[int, ...], Tuple[float, ...], numpy.ndarray]

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

crop_height int

Crop height.

crop_width int

Crop width.

rows int

Image height.

cols int

Image width.

Returns:

Type Description
tuple

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

def albumentations.augmentations.crops.functional.keypoint_random_crop(keypoint, crop_height, crop_width, h_start, w_start, rows, cols) [view source on GitHub]

Keypoint random crop.

Parameters:

Name Type Description
keypoint Union[List[int], List[float], Tuple[int, ...], Tuple[float, ...], numpy.ndarray]

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

crop_height int

Crop height.

crop_width int

Crop width.

h_start float

Crop height start.

w_start float

Crop width start.

rows int

Image height.

cols int

Image width.

Returns:

Type Description

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