Код: Выделить всё
from skimage import data
from skimage import segmentation
from skimage.future import graph
import matplotlib.pyplot as plt
#Load Image
img = data.coffee()
#Segment image
labels = segmentation.slic(img, compactness=30, n_segments=800)
#Create RAG
g = graph.rag_mean_color(img, labels)
#Draw RAG
gplt = graph.draw_rag(labels, g, img)
plt.imshow(gplt)

Однако, если я использую сегментацию.quickshift или сегментацию.felzenszwalb для сегментации изображения, а затем создаю RAG, я получаю сообщение об ошибке draw_rag().
Код: Выделить всё
labels = segmentation.quickshift(img, kernel_size=5, max_dist=5, ratio=0.5)
g = graph.rag_mean_color(img, labels)
gplt = graph.draw_rag(labels, g, img)
labels = segmentation.felzenszwalb(img, scale=100, sigma=0.5, min_size=50)
g = graph.rag_mean_color(img, labels)
gplt = graph.draw_rag(labels, g, img)
Код: Выделить всё
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3032, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
gplt = graph.draw_rag(labels, g, img)
File "C:\Anaconda\lib\site-packages\skimage\future\graph\rag.py", line 429, in draw_rag
out[circle] = node_color
IndexError: index 600 is out of bounds for axis 1 with size 600
Подробнее здесь: https://stackoverflow.com/questions/386 ... gmentation