python - 从 Scikits-Image 初始化 RAG 图的方法

标签 python networkx scikit-image

我想用我自己的数据从 scikit-Image 初始化 RAG 图形对象,以便利用它对可视化的良好支持。

执行此类初始化需要哪些数据?我应该调用什么函数来执行这样的初始化?

最佳答案

现在从 am 图像初始化图形的唯一方法是 rag_mean_color功能。它在图像及其标记数组中输入。

标记数组可以从任何分割算法获得,例如在分割模块中实现的算法。

这是一个使用 Quickshift 方法的快速示例。为了更好地可视化 RAG,您可以使用 matplotlib 的任何颜色图。

from skimage import data, segmentation
from skimage.future import graph
from matplotlib import pyplot as plt


img = data.chelsea()
# A colormap to draw the edge
cmap = plt.get_cmap('autumn')

# Labelled image
qs_labels = segmentation.quickshift(img, ratio=0.5)

# Image with boundaries marked
qs_marked = segmentation.mark_boundaries(img, qs_labels,color=(0,0,0))

# Constructing the RAG
qs_graph = graph.rag_mean_color(img, qs_labels)

#Drawing the RAG
qs_out = graph.draw_rag(qs_labels, qs_graph , qs_marked, colormap=cmap)

plt.imshow(qs_out)
plt.show()

您还可以查看更详细的RAG Drawing Example

谢谢

关于python - 从 Scikits-Image 初始化 RAG 图的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29752203/

相关文章:

python - 获取节点位置和边长

python - 如何将 "SciPy sparse matrix"转换为 "NumPy matrix"?

python - 为 networkx 图创建自己的颜色条

python - opencv ximgproc.slic 和 skimage segmentation.slic 有什么区别?

Python scikit-image 拉取请求 Travis CI Python 2.7 构建失败

Python openpyxl load_workbook 错误 : TypeError (NoneType not Iterable) and ValueError (Max. 值为 180)

python - 循环具有不规则索引增加的函数

python - 为什么我的 python if 语句不起作用?

python - 如何找到最右边黑色像素的位置

python - 强制请求库在 Python 中使用 TLSv1.1 或 TLSv1.2