tlc.core.builtins.types.bb_crop_interface#

Module Contents#

Classes#

Class

Description

BBCropInterface

Interface for creating bounding box crops.

API#

class tlc.core.builtins.types.bb_crop_interface.BBCropInterface#

Interface for creating bounding box crops.

static crop(image_path: str | PIL.Image.Image, bb_dict: dict[str, float | int], bb_schema: tlc.core.schema.Schema, image_height: int = 0, image_width: int = 0, x_max_offset: float = 0.0, y_max_offset: float = 0.0, y_scale_range: tuple[float, float] = (1.0, 1.0), x_scale_range: tuple[float, float] = (1.0, 1.0)) PIL.Image.Image#

Crops an image according to a bounding box and returns the cropped image.

The parameters x_max_offset, y_max_offset, y_scale_range, and x_scale_range are used to introduce random variations in the crop, which can be useful for data augmentation during training.

Parameters:
  • image_path – Path to the image to crop.

  • bb_dict – Dictionary containing bounding box coordinates under the keys X0, Y0, X1, Y1.

  • bb_schema – Schema for the bounding box.

  • image_height – Height of the original image (only necessary if box is in relative coordinates).

  • image_width – Width of the original image (only necessary if box is in relative coordinates).

  • x_max_offset – Maximum random offset of the crop in x direction (both left and right).

  • y_max_offset – Maximum random offset of the crop in y direction (both up and down).

  • y_scale_range – Range of random scaling of the crop in y direction. The first value is the minimum scaling factor, the second value is the maximum scaling factor.

  • x_scale_range – Range of random scaling of the crop in x direction. The first value is the minimum scaling factor, the second value is the maximum scaling factor.

Returns:

Cropped image.