Segmentation Mask: RGB to Object Label
gordon-lim opened this issue · comments
Gordon Lim commented
Could you please point me to the mapping of RGB values to object labels? Or is there no such mapping in one place. Am I to somehow make use the individual instance masks to get the object labels per pixel?
Gordon Lim commented
My apologies, I wasn't looking hard enough. For ease of reference for future visitors, I'll put the relevant code block down below:
with Image.open(fileseg) as io:
seg = np.array(io);
R = seg[:,:,0];
G = seg[:,:,1];
B = seg[:,:,2];
ObjectClassMasks = (R/10).astype(np.int32)*256+(G.astype(np.int32));
The above is from utils/utils_ade20k.py
ObjectClassMasks is an array of object ids assigned to the respective pixel.