skimage 0.17.2

ParametersReturnsBackRef
_round_safe(coords)

When rounding coordinates for line_nd , we want coordinates that are less than 1 apart (always the case, by design) to remain less than one apart. However, NumPy rounds values to the nearest even integer, so:

>>> np.round([0.5, 1.5, 2.5, 3.5, 4.5])
array([0., 2., 2., 4., 4.])

So, for our application, we detect whether the above case occurs, and use np.floor if so. It is sufficient to detect that the first coordinate falls on 0.5 and that the second coordinate is 1.0 apart, since we assume by construction that the inter-point distance is less than or equal to 1 and that all successive points are equidistant.

Parameters

coords : 1D array of float

The coordinates array. We assume that all successive values are equidistant ( np.all(np.diff(coords) = coords[1] - coords[0]) ) and that this distance is no more than 1 ( np.abs(coords[1] - coords[0]) <= 1 ).

Returns

rounded : 1D array of int

The array correctly rounded for an indexing operation, such that no successive indices will be more than 1 apart.

Round coords while ensuring successive values are less than 1 apart.

Examples

This example is valid syntax, but we were not able to check execution
>>> coords0 = np.array([0.5, 1.25, 2., 2.75, 3.5])
... _round_safe(coords0) array([0, 1, 2, 3, 4])
This example is valid syntax, but we were not able to check execution
>>> coords1 = np.arange(0.5, 8, 1)
... coords1 array([0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5])
This example is valid syntax, but we were not able to check execution
>>> _round_safe(coords1)
array([0, 1, 2, 3, 4, 5, 6, 7])
See :

Back References

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

skimage.draw.draw_nd._round_safe

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/draw/draw_nd.py#4
type: <class 'function'>
Commit: