【发布时间】:2016-07-27 18:00:48
【问题描述】:
我正在尝试使用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 方法应该与任何这些方法的段兼容,所以我不确定我做错了什么,存在错误,或者 RAG 只能与 SLIC 分段一起使用方法。有什么建议吗?
【问题讨论】:
标签: python python-2.7 classification image-segmentation scikit-image