tlc.core.builtins.types.segmentation_helper
¶
Module Contents¶
Classes¶
Class |
Description |
---|---|
Helper class for segmentation operations. |
API¶
- class tlc.core.builtins.types.segmentation_helper.SegmentationHelper¶
Helper class for segmentation operations.
- static empty_rle(height: int, width: int) tlc.client.data_format.CocoRle ¶
Create an empty RLE mask with the given dimensions.
- Parameters:
height – Height of the mask
width – Width of the mask
- Returns:
An empty RLE mask dictionary with ‘counts’ and ‘size’ fields
- static mask_from_rle(rle: dict[str, list[int] | bytes]) numpy.ndarray ¶
Convert an RLE mask to a numpy array.
- Parameters:
rle – The RLE mask to convert
- Returns:
A numpy array of shape (H, W, N) containing N binary masks
- static masks_from_rles(rles: list[tlc.client.data_format.CocoRle]) numpy.ndarray ¶
Convert multiple RLE masks to a numpy array.
- Parameters:
rles – List of RLE dictionaries with ‘counts’ and ‘size’ fields
- Returns:
A numpy array of shape (H, W, N) containing N binary masks
- static mask_from_polygons(polygons: list[list[float]], height: int, width: int, relative: bool = False) numpy.ndarray ¶
Convert a list of polygons to a numpy array.
- Parameters:
polygons – The list of polygons to convert
height – The height of the image
width – The width of the image
relative – Whether the polygons are relative to the image size
- Returns:
A numpy array of shape (H, W, N) containing N binary masks
- static polygons_from_mask(mask: numpy.ndarray, relative: bool = False) list[float] ¶
Convert a binary mask to a list of polygons using OpenCV contour detection.
- Parameters:
mask – The binary mask to convert
relative – Whether to return polygons with coordinates relative to image dimensions
- Returns:
List of polygons where each polygon is a flattened list of x,y coordinates
- static polygons_from_rles(rles: list[tlc.client.data_format.CocoRle], relative: bool = False) list[list[float]] ¶
Convert a list of RLE encoded masks to polygons.
- Parameters:
rles – List of RLE dictionaries with ‘counts’ and ‘size’ fields
relative – Whether to return polygons with coordinates relative to image dimensions
- Returns:
List of polygons where each polygon is a flattened list of x,y coordinates
- static rles_from_polygons(polygons: list[list[float]], height: int, width: int, relative: bool = False) list[tlc.client.data_format.CocoRle] ¶
Convert a list of polygons to RLE format.
- Parameters:
polygons – The list of polygons to convert
height – The height of the image
width – The width of the image
relative – Whether the polygons are relative to the image size
- Returns:
List of RLE dictionaries with ‘counts’ and ‘size’ fields
- static rles_from_masks(masks: numpy.ndarray) list[tlc.client.data_format.CocoRle] ¶
Convert a stack of binary masks to RLE format.
- Parameters:
masks – A numpy array of shape (H, W, N) containing N binary masks
- Returns:
List of RLE dictionaries with ‘counts’ and ‘size’ fields
- static bbox_from_rle(rle: tlc.client.data_format.CocoRle) list[float] ¶
Convert an RLE mask to a bounding box.
- Parameters:
rle – The RLE mask to convert
- Returns:
A list of bounding box coordinates [x1, y1, x2, y2]