1

我試圖使用Skimage包中的工具分割圖像之後創建區域鄰接圖。使用文檔中的示例,我可以使用SLIC分割圖像併成功創建RAG。快速轉換分段滑雪區域鄰接圖(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方法應符合上述任何一種方法段兼容,所以我不知道如果我做錯事,有一個bug,或者可以RAG只能用於SLIC分割方法。有什麼建議麼?

回答

0

似乎這是Skimage 0.11.2中的一個問題,但在版本0.12.3中已修復。