bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / graph / _graph / pixel_graph
function
skimage.graph._graph:pixel_graph
source: /dev/scikit-image/src/skimage/graph/_graph.py :34
Signature
def pixel_graph ( image , * , mask = None , edge_function = None , connectivity = 1 , spacing = None , sparse_type = matrix ) Summary
Create an adjacency graph of pixels in an image.
Extended Summary
Pixels where the mask is True are nodes in the returned graph, and they are connected by edges to their neighbors according to the connectivity parameter. By default, the value of an edge when a mask is given, or when the image is itself the mask, is the Euclidean distance between the pixels.
However, if an int- or float-valued image is given with no mask, the value of the edges is the absolute difference in intensity between adjacent pixels, weighted by the Euclidean distance.
Parameters
image: arrayThe input image. If the image is of type bool, it will be used as the mask as well.
mask: array of boolWhich pixels to use. If None, the graph for the whole image is used.
edge_function: callableA function taking an array of pixel values, and an array of neighbor pixel values, and an array of distances, and returning a value for the edge. If no function is given, the value of an edge is just the distance.
connectivity: intThe square connectivity of the pixel neighborhood: the number of orthogonal steps allowed to consider a pixel a neighbor. See scipy.ndimage.generate_binary_structure for details.
spacing: tuple of floatThe spacing between pixels along each axis.
sparse_type: {"matrix", "array"}, optionalThe return type of graph, either scipy.sparse.csr_array or scipy.sparse.csr_matrix (default).
Returns
graph: scipy.sparse.csr_matrix or scipy.sparse.csr_arrayA sparse adjacency matrix in which entry (i, j) is 1 if nodes i and j are neighbors, 0 otherwise. Depending on
sparse_type, this can be returned as a scipy.sparse.csr_array.nodes: array of intThe nodes of the graph. These correspond to the raveled indices of the nonzero pixels in the mask.
Aliases
-
skimage.graph.pixel_graph