Solved by MariosOreo in post #2 
              
              
                Okay, I have solve it by myself, but I don’t know whether it is the efficient one. 
If you have other ideas, I will also appreciate it! 
mask_mapping = {
    (255, 255, 0):   0,
    (0, 255, 255):   1,
    (255, 255, 255): 2,
}
for k in mask_mapping:
    label[(label == k).all(axis=2)] = mask_mappin…