RAG
-
class skimage.future.graph.RAG(label_image=None, connectivity=1, data=None, **attr)
[source] -
Bases:
networkx.classes.graph.Graph
The 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_image
will 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
u
andv
while updating max node id.See also
networkx.Graph.add_edge()
.
-
add_node(n, attr_dict=None, **attr)
[source] -
Add node
n
while 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
src
anddst
.The new combined node is adjacent to all the neighbors of
src
anddst
.weight_func
is 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
n
forsrc and `dst
,weight_func
will be called as follows:weight_func(src, dst, n, *extra_arguments, **extra_keywords)
.src
,dst
andn
are 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_place
isFalse
the resulting node has a new id, rather thandst
.
-
next_id()
[source] -
Returns the
id
for the new node to be inserted.The current implementation returns one more than the maximum
id
.Returns: id : int
The
id
of the new node to be inserted.
-
Please login to continue.