> ## 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.

# Objects.bitmask

## ArrayProtocol Objects

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

```python theme={"dark"}
class BitmaskCoordinates()
```

#### \_\_init\_\_

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

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

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

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