You can take only the one, which has the biggest area. You can split every color by channels and compute the maximum area. It will be something like this

```
import cv2
import numpy as np
mask = cv2.imread(mask_path)
# Let's find unique colors of the mask
unique_colors = np.unique(mask.reshape(-1, mask.shape[2]), axis=0)
masks = np.zeros(mask.shape)
for color in unique_colors:
object_mask = np.where(mask == color, 1, 0)
object_mask = np.prod(object_mask, axis=-1)
masks = np.dstack([object_mask, masks])
```

Now every channel of the mask will corresponde to a binary mask of each object (color). After this you will have to compute the max area.

**Remember our first channel contains black mask because of initialization, also first color of unique_colors could have been black (0, 0, 0).**

```
masks = masks[:, :, 2:]
# Because each pixel is 1 or 0, the area can be computed like this
areas = np.sum(masks, axis=(0, 1))
max_area_arg = np.argmax(areas)
mask = masks[:, :, max_area_arg] # This is the mask you want
```