Closed amida47 closed 2 years ago
You can do something like this to get all RGB color codes in the image:
from PIL import Image
from collections import defaultdict
im = Image.open('example.jpg')
by_color = defaultdict(int)
for pixel in im.getdata():
by_color[pixel] += 1
by_color
Next, add/change category_colors
in the notebook.
But I have grayscale masks so there is only one channel to the image and your code expect an 3 channels RGB image
Ah! Maybe not the best solution, but I would convert them to rgb:
backtorgb = cv2.cvtColor(gray,cv2.COLOR_GRAY2RGB)
I want to use your code but I have grayscale masks, where each category is coded with a value, could you guide me to what should be changed in order to achieve this. Thanks