在使用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)
但是,如果我使用segmentation.quickshift
或segmentation.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方法应该与这些方法中的任何一个方法的片段兼容,所以我不确定我是否做错了什么,是否有bug,或者RAG只能与SLIC分割方法一起使用。有什么建议吗?
发布于 2016-07-28 05:21:18
这似乎是Skimage 0.11.2
中的一个问题,但在0.12.3
版本中已修复。
https://stackoverflow.com/questions/38620129
复制相似问题