skimage 0.17.2

ParametersReturnsBackRef
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.

Parameters

ar_shape : array-like of ints

The shape of the space embedding the grid. len(ar_shape) is the number of dimensions.

n_points : int

The (approximate) number of points to embed in the space.

Returns

slices : tuple of slice objects

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.

versionchanged

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`.

Examples

This example is valid syntax, but we were not able to check execution
>>> ar = np.zeros((20, 40))
... g = regular_grid(ar.shape, 8)
... g (slice(5, None, 10), slice(5, None, 10))
This example is valid syntax, but we were not able to check execution
>>> ar[g] = 1
... ar.sum() 8.0
This example is valid syntax, but we were not able to check execution
>>> ar = np.zeros((20, 40))
... g = regular_grid(ar.shape, 32)
... g (slice(2, None, 5), slice(2, None, 5))
This example is valid syntax, but we were not able to check execution
>>> ar[g] = 1
... ar.sum() 32.0
This example is valid syntax, but we were not able to check execution
>>> ar = np.zeros((3, 20, 40))
... g = regular_grid(ar.shape, 8)
... g (slice(1, None, 3), slice(5, None, 10), slice(5, None, 10))
This example is valid syntax, but we were not able to check execution
>>> ar[g] = 1
... ar.sum() 8.0
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.util._regular_grid.regular_grid

Local connectivity graph

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


File: /skimage/util/_regular_grid.py#4
type: <class 'function'>
Commit: