This solution is good when we have the target segmentations in the range of the index we are mapping to.
i.e if C classes, the intensity of the segmentation mask ranges from 1 to C.
However, how do we one-hot encode a segmentation mask with 5 classes but intensities in the range 0,255 with only 5 unique values in the mask?
Please let me know if the question is not clear.