How To Convert A Label Matrix To Colour Matrix For Image Segmentation?
I have a label matrix of 256*256 for example. And the classes are 0-11 so 12 classes. I want to convert the label matrix to colour matrix. I tried do it in a code like this `for
Solution 1:
You are looking into indexed RGB images - an RGB image where you have a fixed "pallet" of colors, each pixel indexes to one of the colors of the pallet. See this page for more information.
from PIL import Image
img = Image.fromarray(x, mode="P")
img.putpalette([
255, 255, 255, # index 0
144, 0, 0, # index 1
0, 255, 0, # index 2
0, 0, 255, # index 3
# ... and so on, you can take it from here.
])
img.show()
Post a Comment for "How To Convert A Label Matrix To Colour Matrix For Image Segmentation?"