sklearn.feature_extraction.image.grid_to_graph

sklearn.feature_extraction.image.grid_to_graph(n_x, n_y, n_z=1, *, mask=None, return_as=<class 'scipy.sparse.coo.coo_matrix'>, dtype=<class 'int'>) [source]

Graph of the pixel-to-pixel connections

Edges exist if 2 voxels are connected.

Parameters
n_xint

Dimension in x axis

n_yint

Dimension in y axis

n_zint, default=1

Dimension in z axis

maskndarray of shape (n_x, n_y, n_z), dtype=bool, default=None

An optional mask of the image, to consider only part of the pixels.

return_asnp.ndarray or a sparse matrix class, default=sparse.coo_matrix

The class to use to build the returned adjacency matrix.

dtypedtype, default=int

The data of the returned sparse matrix. By default it is int

Notes

For scikit-learn versions 0.14.1 and prior, return_as=np.ndarray was handled by returning a dense np.matrix instance. Going forward, np.ndarray returns an np.ndarray, as expected.

For compatibility, user code relying on this method should wrap its calls in np.asarray to avoid type issues.

© 2007–2020 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/0.24/modules/generated/sklearn.feature_extraction.image.grid_to_graph.html