{ } Raw JSON

bundles / skimage latest / skimage / graph / _rag / show_rag

function

skimage.graph._rag:show_rag

source: /dev/scikit-image/src/skimage/graph/_rag.py :458

Signature

def   show_rag ( labels rag image border_color = black edge_width = 1.5 edge_cmap = magma img_cmap = bone in_place = True ax = None )

Summary

Show a Region Adjacency Graph on an image.

Extended Summary

Given a labelled image and its corresponding RAG, show the nodes and edges of the RAG on the image with the specified colors. Edges are displayed between the centroid of the 2 adjacent regions in the image.

Parameters

labels : ndarray, shape (M, N)

The labelled image.

rag : RAG

The Region Adjacency Graph.

image : ndarray, shape (M, N[, 3])

Input image. If colormap is None, the image should be in RGB format.

border_color : color spec, optional

Color with which the borders between regions are drawn.

edge_width : float, optional

The thickness with which the RAG edges are drawn.

edge_cmap : :py:class:`matplotlib.colors.Colormap`, optional

Any matplotlib colormap with which the edges are drawn.

img_cmap : :py:class:`matplotlib.colors.Colormap`, optional

Any matplotlib colormap with which the image is draw. If set to None the image is drawn as it is.

in_place : bool, optional

If set, the RAG is modified in place. For each node n the function will set a new attribute rag.nodes[n]['centroid'].

ax : :py:class:`matplotlib.axes.Axes`, optional

The axes to draw on. If not specified, new axes are created and drawn on.

Returns

lc : :py:class:`matplotlib.collections.LineCollection`

A collection of lines that represent the edges of the graph. It can be passed to the matplotlib.figure.Figure.colorbar function.

Examples

from skimage import data, segmentation, graph
import matplotlib.pyplot as plt
img = data.coffee()
labels = segmentation.slic(img)
g =  graph.rag_mean_color(img, labels)
lc = graph.show_rag(labels, g, img)
cbar = plt.colorbar(lc)

Aliases

  • skimage.graph.show_rag