来自快速分割的Skimage Region Adjacency Graph(RAG)

时间:2016-07-27 18:00:49

标签: python python-2.7 classification image-segmentation scikit-image

我尝试使用Skimage包中的工具分割图像后创建区域邻接图。使用文档中的示例,我可以使用SLIC对图像进行分段,并成功创建RAG。

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)

Successful RAG

但是,如果我使用segmentation.quickshiftsegmentation.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 "<ipython-input-34-c0784622a6c7>", line 1, in <module>
    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

文档似乎表明RAG方法应该与这些方法中的任何一个方面的段兼容,因此我不确定我是否做错了,有错误,或者RAG可以仅用于SLIC分割方法。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

似乎这是Skimage 0.11.2中的一个问题,但已在版本0.12.3中修复。