RAG
-
class skimage.future.graph.RAG(label_image=None, connectivity=1, data=None, **attr)[source] -
Bases:
networkx.classes.graph.GraphThe Region Adjacency Graph (RAG) of an image, subclasses networx.Graph
Parameters: label_image : array of int
An initial segmentation, with each region labeled as a different integer. Every unique value in
label_imagewill correspond to a node in the graph.connectivity : int in {1, ...,
label_image.ndim}, optionalThe connectivity between pixels in
label_image. For a 2D image, a connectivity of 1 corresponds to immediate neighbors up, down, left, and right, while a connectivity of 2 also includes diagonal neighbors. Seescipy.ndimage.generate_binary_structure.data : networkx Graph specification, optional
Initial or additional edges to pass to the NetworkX Graph constructor. See
networkx.Graph. Valid edge specifications include edge list (list of tuples), NumPy arrays, and SciPy sparse matrices.**attr : keyword arguments, optional
Additional attributes to add to the graph.
-
__init__(label_image=None, connectivity=1, data=None, **attr)[source]
-
add_edge(u, v, attr_dict=None, **attr)[source] -
Add an edge between
uandvwhile updating max node id.See also
networkx.Graph.add_edge().
-
add_node(n, attr_dict=None, **attr)[source] -
Add node
nwhile updating the maximum node id.See also
networkx.Graph.add_node().
-
copy()[source] -
Copy the graph with its max node id.
See also
networkx.Graph.copy().
-
merge_nodes(src, dst, weight_func=, in_place=True, extra_arguments=[], extra_keywords={})[source] -
Merge node
srcanddst.The new combined node is adjacent to all the neighbors of
srcanddst.weight_funcis called to decide the weight of edges incident on the new node.Parameters: src, dst : int
Nodes to be merged.
weight_func : callable, optional
Function to decide edge weight of edges incident on the new node. For each neighbor
nforsrc and `dst,weight_funcwill be called as follows:weight_func(src, dst, n, *extra_arguments, **extra_keywords).src,dstandnare IDs of vertices in the RAG object which is in turn a subclass ofnetworkx.Graph.in_place : bool, optional
If set to
True, the merged node has the iddst, else merged node has a new id which is returned.extra_arguments : sequence, optional
The sequence of extra positional arguments passed to
weight_func.extra_keywords : dictionary, optional
The dict of keyword arguments passed to the
weight_func.Returns: id : int
The id of the new node.
Notes
If
in_placeisFalsethe resulting node has a new id, rather thandst.
-
next_id()[source] -
Returns the
idfor the new node to be inserted.The current implementation returns one more than the maximum
id.Returns: id : int
The
idof the new node to be inserted.
-
Please login to continue.