segmentation

Utilities* for converting segmentation annotations between different formats.

Classes

CompressedRLEMaskConverter

MaskConverter

PolygonMaskConverter

RLEMaskConverter

Functions

coco_to_binary_masks(ch, dest_dir[, scaling])

Converts annotations from COCO to binary masks.

compressed_rle_to_mask(rle_code[, height, ...])

Converts a compressed RLE to a binary mask with the given output dtype.

compute_polygon_area(polygon)

Computes a segmentation area from its polygon coordinates.

convert_to_mask(segmentation, height, width, ...)

Converts a segmentation to a binary mask.

convert_to_mode(segmentation, mode, height, ...)

Converts a segmentation to the specified mode.

decode_mask(code, mode, **kwargs)

Decodes a mask using the specified mode. :param code: the encoded mask. :param mode: the mode to use for decoding the mask. :param **kwargs: extra parameters such as: - height and width to indicate the shape of the output mask (if mode in [cRLE, polygon]). - value to indicate the value of the zero-valued pixels in the output mask (if mode=polygon). - dtype to indicate the type of the output mask (if mode in [RLE, cRLE, polygon]).

encode_mask(mask, mode, **kwargs)

Encodes a mask using the specified :param mask: a binary mask as a numpy array.

get_segmentation_mode(segmentation)

Automatically detect the segmentation format: RLE, cRLE or polygon.

mask_to_compressed_rle(mask, **kwargs)

Converts a binary mask to compressed RLE format.

mask_to_polygon(mask[, simplify_tolerance])

Converts segmentation mask to a list of polygons.

mask_to_rle(binary_mask, **kwargs)

Converts a binary mask to RLE encoding.

polygon_to_mask(polygon_code[, width, ...])

Creates and returns a mask from polygon in COCO format.

rle_to_mask(rle_code[, dtype])

Converts an RLE to a binary mask with the given output dtype.