Dear Mr. Ptrblck,
Thank you very much for the suggestion. I am sorry for the late reply. I have been trying other alternatives    read from this forum. In fact, my data are RGB images from which I generated the corresponding labels. After checking carefully, I noticed that the labels are also having three channels. Then I have tried to fix them as follows.
label = np.where(label_img > 0.0, 1, 0)

When I print the labels out, the shape is (N,H,W). Please, am I right doing it this way? How can I map the colors to obtain grayscale labels?