Skip to content

Object class to color mapping for semantic segmentation #528

Answered by mattdeitke
zerolatnc asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @sashi2295!

I'll give a contrived example with smaller dimensions, since it's easier to visualize.

Consider that the (semantic) segmentation masks will appear in the following form, where 0, 1, and 2 are each correspond to separate object type segmentation:

import numpy as np

segmentation = np.random.randint(low=0, high=3, size=(3, 3))
array([[2, 2, 0],
       [1, 2, 1],
       [0, 0, 1]])

If the object_id_to_color does something like assign 2 to the Cup object type, we can then condition the segmentation where each entry is equal to 2, as in:

condition = (segmentation == 2)
array([[False,  True, False],
       [ True, False, False],
       [ True,  True,  True]])

Now, the RGB frame

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@mattdeitke
Comment options

@zerolatnc
Comment options

@zerolatnc
Comment options

@winthos
Comment options

winthos Nov 23, 2020
Collaborator

@zerolatnc
Comment options

Answer selected by zerolatnc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #528 on November 20, 2020 16:11.