skimage 0.17.2

NotesParametersReturnsBackRef
medial_axis(image, mask=None, return_distance=False)

Notes

This algorithm computes the medial axis transform of an image as the ridges of its distance transform.

The different steps of the algorithm are as follows

  • A lookup table is used, that assigns 0 or 1 to each configuration of the 3x3 binary square, whether the central pixel should be removed or kept. We want a point to be removed if it has more than one neighbor and if removing it does not change the number of connected components.

  • The distance transform to the background is computed, as well as the cornerness of the pixel.

  • The foreground (value of 1) points are ordered by the distance transform, then the cornerness.

  • A cython function is called to reduce the image to its skeleton. It processes pixels in the order determined at the previous step, and removes or maintains a pixel according to the lookup table. Because of the ordering, it is possible to process all pixels in only one pass.

Parameters

image : binary ndarray, shape (M, N)

The image of the shape to be skeletonized.

mask : binary ndarray, shape (M, N), optional

If a mask is given, only those elements in :None:None:`image` with a true value in :None:None:`mask` are used for computing the medial axis.

return_distance : bool, optional

If true, the distance transform is returned as well as the skeleton.

Returns

out : ndarray of bools

Medial axis transform of the image

dist : ndarray of ints, optional

Distance transform of the image (only returned if :None:None:`return_distance` is True)

Compute the medial axis transform of a binary image

See Also

skeletonize

Examples

This example is valid syntax, but we were not able to check execution
>>> square = np.zeros((7, 7), dtype=np.uint8)
... square[1:-1, 2:-2] = 1
... square array([[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
This example is valid syntax, but we were not able to check execution
>>> medial_axis(square).astype(np.uint8)
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 1, 0, 0],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 0, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
See :

Back References

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

skimage.morphology._skeletonize.medial_axis skimage.morphology._skeletonize.thin

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/morphology/_skeletonize.py#364
type: <class 'function'>
Commit: