ptrblck:

Based on your masks output, it seems that you might be dealing with a multi-label segmentation, where each pixel might belong to zero, one, or multiple classes.


Sorry if my code may be wrong somwhere, but in my case, each pixel can only belong to one class i.e. to either of one bands of the output bands (shown in code snippet).
I also edited my previous code to show more data with shapes.