interpretation in graph

I am working on a project where I have to segment the image using multi-class segmentation (3 classes) on microscopic images.

Now let's say that I am segmenting solid, liquid and gas images (this is an example made up for asking the question because I am not allowed to discuss anything about the project :( ), I have pixel wise segmented solid, liquid and gas. But now, once I have segmented these images, I want to put the results on already existing graph. for example, if the water in images is segmented as red in color, then I want to interpret this result in already existing graph with the red color as an indicator(I have added images as example), same goes for blue color as solid.

Can anyone please help me how to do this? I am using u-net architecture for semantic segmentation. This is my first question, although I have tried to explain the question to best of my ability, please let me know if more information is needed to help me answer this question. I initially asked this question on stackoverflow (https://stackoverflow.com/questions/71341512/how-to-visualize-segmented-labels-in-a-already-existing-graph) but then I was advised to post it here. Thank you in advance. [segmented imagessolid, liquid, gas state graph


1 Answer 1


You can simply use the pixel predictions from your network, go through all of your classes, and give each pixel that belongs to a specific class the corresponding color. You can take some inspiration from the following labelVisualize function from a unet repository:

def labelVisualize(num_class, color_dict, img):
    img = img[:, :, 0] if len(img.shape) == 3 else img
    img_out = np.zeros(img.shape + (3,))
    for i in range(num_class):
        img_out[img == i, :] = color_dict[i]
    return img_out / 255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.