문제

Assuming that you have the result of a superpixeling algorithm such as SLIC Superpixel Algorithms

segments_slic = slic(img, n_segments=250, compactness=10, sigma=1)

How can you display the image as being colored differently for each superpixel with a preset color (say, you know beforehand which color coresponds to each superpixel, as in a semantic labelling problem.

I need something similar to

imshow(mark_boundaries(img, segments_slic))

but instead of just marking the boundaries, I need semantic segmentation with the labels that I work with

도움이 되었습니까?

해결책

If you know which value you'd like to assign to a specific position, say at (i, j), make a copy of the labels

new_labels = labels.copy()

Then proceed to "rename" the labels:

new_labels[labels == labels[i, j]] = new_label_value
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top