FPCRasmus:

ypeError: ‘bool’ object is not subscriptable


I think this is a problem related to numpy, not sure which version you’re using. I am using
np.__version__
'1.17.4'

and it does not have this problem. To confirm, here’s a snapshot of one of the masks:
[False, False, False, ..., False, False, False],
False, False, False, ..., False, False, False],
False, False, False, ..., False, False, False]]])

type(masks[0][0][0])
<class 'numpy.bool_'>

the first 0 is the mask index, and the two other zeros are the xy location in the mask.
if you are using an earlier numpy version, just upgrade it and test again.
NB. Note sure why in the ONE MASK example above your pixel/mask-values show a triplet in (note, iris = (1,1,1) pupil = (2,2,2))!? Each generated mask should only have one channel .That being said, imagine the original mask that contains the labels (call it the color-encoded-mask), before converting to three binary masks, as a gray-level image with one-channel filed with 0s, 1s, and 2s. The two masks are generated from the color-encoded-mask by removing the background (the 0s) using obj_ids = np.unique(mask)[1:], followed by  masks = mask == obj_ids[:, None, None].