> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Common.bitmask operations.bitmask operations

#### encord\_rle\_to\_coco\_rle

```python theme={"dark"}
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

```python theme={"dark"}
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

```python theme={"dark"}
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
