Skip to main content
A Bitmask is a type of annotation on the Encord platform that allows for pixel-wise segmentation of an image, which can be useful when bounding boxes and polygons do not provide enough precision, or when topologically separate regions belonging to the same class need to be labeled.

Upload Bitmask Labels to Encord

If there are pre-existing Bitmask annotations, previously created in Encord or any other software, they can be uploaded to Encord using the SDK. The following code example shows how to read a bitmask from a file, and upload it:

Decode Bitmask Labels

Bitmask labels exported from Encord are encoded in an rleString. This rleString can be converted to an image or a binary array.

Creating Bitmask Images from JSON Export

The script below must only be used to decode bitmasks that are exported in the JSON format.
The following script takes your exported JSON file, finds the rleString, and converts it into an image.

Creating a Binary Array

The rleStringcan also be converted into an array of 1’s and 0’s using the script below.

Creating Bitmask Images from COCO Export

Use the COCO API to decode Bitmasks when using the COCO export format.

Export Bitmasks

See our documentation on exporting Bitmasks here.