I'm not sure if I completely understand this, but would the following have the same effect:

```python
out_labels = np.empty(labels.shape + (len(unique_labels),), dtype=bool)
for n, i in enumerate(unique_labels):
    out_labels[..., n] = (labels == i)
```