draw_rag
-
skimage.future.graph.draw_rag(labels, rag, img, border_color=None, node_color='#ffff00', edge_color='#00ff00', colormap=None, thresh=inf, desaturate=False, in_place=True)
[source] -
Draw a Region Adjacency Graph on an image.
Given a labelled image and its corresponding RAG, draw the nodes and edges of the RAG on the image with the specified colors. Nodes are marked by the centroids of the corresponding regions.
Parameters: labels : ndarray, shape (M, N)
The labelled image.
rag : RAG
The Region Adjacency Graph.
img : ndarray, shape (M, N, 3)
Input image.
border_color : colorspec, optional
Any matplotlib colorspec.
node_color : colorspec, optional
Any matplotlib colorspec. Yellow by default.
edge_color : colorspec, optional
Any matplotlib colorspec. Green by default.
colormap : colormap, optional
Any matplotlib colormap. If specified the edges are colormapped with the specified color map.
thresh : float, optional
Edges with weight below
thresh
are not drawn, or considered for color mapping.desaturate : bool, optional
Convert the image to grayscale before displaying. Particularly helps visualization when using the
colormap
option.in_place : bool, optional
If set, the RAG is modified in place. For each node
n
the function will set a new attributerag.node[n]['centroid']
.Returns: out : ndarray, shape (M, N, 3)
The image with the RAG drawn.
Examples
>>> from skimage import data, segmentation >>> from skimage.future import graph >>> img = data.coffee() >>> labels = segmentation.slic(img) >>> g = graph.rag_mean_color(img, labels) >>> out = graph.draw_rag(labels, g, img)
Please login to continue.