regular_grid(ar_shape, n_points)
The returned points (as slices) should be as close to cubically-spaced as possible. Essentially, the points are spaced by the Nth root of the input array size, where N is the number of dimensions. However, if an array dimension cannot fit a full step size, it is "discarded", and the computation is done for only the remaining dimensions.
The shape of the space embedding the grid. len(ar_shape)
is the number of dimensions.
The (approximate) number of points to embed in the space.
A slice along each dimension of :None:None:`ar_shape`
, such that the intersection of all the slices give the coordinates of regularly spaced points.
In scikit-image 0.14.1 and 0.15, the return type was changed from a list to a tuple to ensure :None:None:`compatibility with Numpy 1.15`
and higher. If your code requires the returned result to be a list, you may convert the output of this function to a list with:
>>> result = list(regular_grid(ar_shape=(3, 20, 40), n_points=8))
<Unimplemented 'target' '.. _compatibility with NumPy 1.15: https://github.com/numpy/numpy/blob/master/doc/release/1.15.0-notes.rst#deprecations'>
Find :None:None:`n_points`
regularly spaced along :None:None:`ar_shape`
.
>>> ar = np.zeros((20, 40))This example is valid syntax, but we were not able to check execution
... g = regular_grid(ar.shape, 8)
... g (slice(5, None, 10), slice(5, None, 10))
>>> ar[g] = 1This example is valid syntax, but we were not able to check execution
... ar.sum() 8.0
>>> ar = np.zeros((20, 40))This example is valid syntax, but we were not able to check execution
... g = regular_grid(ar.shape, 32)
... g (slice(2, None, 5), slice(2, None, 5))
>>> ar[g] = 1This example is valid syntax, but we were not able to check execution
... ar.sum() 32.0
>>> ar = np.zeros((3, 20, 40))This example is valid syntax, but we were not able to check execution
... g = regular_grid(ar.shape, 8)
... g (slice(1, None, 3), slice(5, None, 10), slice(5, None, 10))
>>> ar[g] = 1See :
... ar.sum() 8.0
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.util._regular_grid.regular_grid
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them