Skip to main content

encord_rle_to_coco_rle

def encord_rle_to_coco_rle(encord_rle_string: str, *, height: int,
                           width: int) -> str
Convert an Encord-compatible RLE string to a COCO-compatible RLE counts string. Encord bitmasks are encoded from row-major mask data. COCO RLE counts are encoded from column-major mask data, as produced by pycocotools.

coco_rle_to_encord_rle

def coco_rle_to_encord_rle(coco_rle_string: str, *, height: int,
                           width: int) -> str
Convert a COCO-compatible RLE counts string to an Encord-compatible RLE string. COCO RLE counts are encoded from column-major mask data, as produced by pycocotools. Encord bitmasks are encoded from row-major mask data.

ranges_to_rle_counts

def ranges_to_rle_counts(ranges: Sequence[Tuple[int, int]]) -> List[int]
Convert sorted non-overlapping ranges to RLE counts. This is O(number of ranges) rather than O(number of points), making it efficient for large point sets represented as ranges. Arguments:
  • ranges - Sorted list of (start, end) tuples representing inclusive ranges. Ranges must be non-overlapping and sorted by start.
Returns: List of RLE counts alternating between empty and present runs