A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.image.grid_to_graph.html below:

grid_to_graph — scikit-learn 1.8.dev0 documentation

grid_to_graph#

Graph of the pixel-to-pixel connections.

Edges exist if 2 voxels are connected.

Read more in the User Guide.

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.

Returns:
graphnp.ndarray or a sparse matrix class

The computed adjacency matrix.

Examples

>>> import numpy as np
>>> from sklearn.feature_extraction.image import grid_to_graph
>>> shape_img = (4, 4, 1)
>>> mask = np.zeros(shape=shape_img, dtype=bool)
>>> mask[[1, 2], [1, 2], :] = True
>>> graph = grid_to_graph(*shape_img, mask=mask)
>>> print(graph)
<COOrdinate sparse matrix of dtype 'int64'
  with 2 stored elements and shape (2, 2)>
  Coords    Values
  (0, 0)    1
  (1, 1)    1

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4