Skip to main content

ArrayProtocol Objects

@runtime_checkable
class ArrayProtocol(Protocol)
Protocol for any object implementing :ref:NumPy array interface <https://numpy.org/doc/stable/reference/arrays.interface.html>

BitmaskCoordinates Objects

class BitmaskCoordinates()

__init__

def __init__(source: Union[ArrayProtocol, BitmaskCoordinates.EncodedBitmask,
                           Dict[str, Any]])
Creates a BitmaskCoordinates object from a NumPy array, or other objects that implement :ref:NumPy array interface <https://numpy.org/doc/stable/reference/arrays.interface.html>, such as Pillow images. For detailed information please refer to :ref:bitmask tutorial <tutorials/bitmasks:Bitmasks>

from_dict

@staticmethod
def from_dict(d: Dict[str, Any]) -> BitmaskCoordinates
This method is used to construct object from Encord bitmask dictionary format. In most cases external users donโ€™t need it. Please consider just passing bitmask numpy array compatible object to the BitmaskCoordinates constructor.

to_dict

def to_dict() -> Dict[str, Any]
This method is used to serialize the object to Encord bitmask dictionary format. In most cases external users donโ€™t need it. Please consider using .to_numpy_array method, or just pass this BitmaskCoordinates objects to a constructor of any class that supports numpy array protocol, such as NumPy array, Pillow image, etc.

to_numpy_array

def to_numpy_array()
Converts the mask to a 2D numpy array with dtype bool. Numpy needs to be installed for this call to work.