gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:44:14 26 4
gpt4 key购买 nike

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

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

最佳答案

现在从图像初始化图形的唯一方法是 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com